47 lines
815 B
C
47 lines
815 B
C
#ifndef FILE_H
|
|
#define FILE_H
|
|
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#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;
|
|
uint64_t lines;
|
|
} File;
|
|
|
|
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
|