aboutsummaryrefslogtreecommitdiff
path: root/include/fs.h
blob: 0698871f795cddabbad9c9256c8d8a48be5a9f79 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
 * @file fs.h
 */
#ifndef SPM_FSTREE_H
#define SPM_FSTREE_H

#define SPM_FSTREE_FLT_NONE 1 << 0
#define SPM_FSTREE_FLT_CONTAINS 1 << 1
#define SPM_FSTREE_FLT_ENDSWITH 1 << 2
#define SPM_FSTREE_FLT_STARTSWITH 1 << 3
#define SPM_FSTREE_FLT_RELATIVE 1 << 4

typedef struct {
    char *name;
    struct stat *st;
} FSRec;

typedef struct {
    char *root;
    FSRec **record;
    size_t num_records;
    size_t _num_alloc;
} FSTree;

typedef struct {
    char *root;
    struct dirent **record;
    size_t records;
    size_t _num_alloc;
} FSList;

int _fstree_compare(const FTSENT **a, const FTSENT **b);
FSTree *fstree(const char *_path, char **filter_by, unsigned int filter_mode);
void fstree_free(FSTree *fsdata);
char *fstree_search(FSTree *fsdata, char *path);
FSList *fslist(const char *path);
void fslist_free(FSList *fsdata);
int exists(const char *filename);
int rmdirs(const char *_path);
long int get_file_size(const char *filename);
int mkdirs(const char *_path, mode_t mode);
char *dirname(const char *_path);
char *basename(char *path);
int rsync(const char *_args, const char *_source, const char *_destination);
char *human_readable_size(uint64_t n);
char *expandpath(const char *_path);
char *spm_mkdtemp(const char *base, const char *name, const char *extended_path);
int touch(const char *path);
char **file_readlines(const char *filename, size_t start, size_t limit, ReaderFn *readerFn);
#endif //SPM_FSTREE_H