From d12170bb0cb936f1e48a677dbd96822db55bbda3 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 3 Jun 2020 00:10:25 -0400 Subject: Refactor fstree (#39) * Refactor fstree, fstree_free, FSTree type * Add FSRec structure * Refactor fstree usage * Decrease starting size of FSTree structure * Check if ManifestPackage is NULL, not if the requirements array if NULL * Use num_requirements instead of '!= NULL' * Add fstree test --- include/fs.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'include/fs.h') diff --git a/include/fs.h b/include/fs.h index 81acd92..0698871 100644 --- a/include/fs.h +++ b/include/fs.h @@ -10,12 +10,16 @@ #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; - char **dirs; - size_t dirs_length; - char **files; - size_t files_length; + FSRec **record; + size_t num_records; + size_t _num_alloc; } FSTree; typedef struct { @@ -28,6 +32,7 @@ typedef struct { 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); -- cgit