feat(file): added utility functions to copy a file and insert/delete lines of the file

This commit is contained in:
lisk77 2025-09-03 23:42:50 +02:00
parent c8e5cd7095
commit 1dd9e2cbca
2 changed files with 170 additions and 8 deletions

View file

@ -6,6 +6,22 @@
#include <stdio.h>
#include <stdint.h>
#include <sys/stat.h>
#include <math.h>
#include <zlib.h>
#ifdef _WIN32
#include <windows.h>
#ifndef PATH_MAX
#define PATH_MAX MAX_PATH
#endif
#else
#include <limits.h>
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
#endif
#include "hash.h"
typedef struct {
char** content;
@ -15,10 +31,17 @@ typedef struct {
typedef struct {
mode_t mode;
char* name;
char* hash;
} FileInfo;
File* new_empty_file();
File* new_file(const char*);
File* from_string(char*);
File* slice_file(File*, uint64_t, uint64_t);
File* copy_file(File* original);
int insert_line(File*, char*, size_t);
int delete_line(File*, size_t);
int snapshot_file(char*, char*, size_t, char*);
void free_file(File*);
#endif // FILE_H