diff options
author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2020-06-03 00:10:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-03 00:10:25 -0400 |
commit | d12170bb0cb936f1e48a677dbd96822db55bbda3 (patch) | |
tree | 1bd69fbd6460dff6f50e7a13e54693a534590104 /lib/relocation.c | |
parent | 6c140c35ae7bf2b5e6633f63e2bc2fba14fc22bc (diff) | |
download | spmc-d12170bb0cb936f1e48a677dbd96822db55bbda3.tar.gz |
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
Diffstat (limited to 'lib/relocation.c')
-rw-r--r-- | lib/relocation.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/relocation.c b/lib/relocation.c index fa03aee..a14c8e4 100644 --- a/lib/relocation.c +++ b/lib/relocation.c @@ -314,17 +314,20 @@ int prefixes_write(const char *output_file, int mode, char **prefix, const char fprintf(SYSERROR); return -1; } - for (size_t i = 0; i < fsdata->files_length; i++) { - if (file_is_metadata(fsdata->files[i])) { + for (size_t i = 0; i < fsdata->record; i++) { + if (S_ISDIR(fsdata->record[i]->st->st_mode)) { + continue; + } + if (file_is_metadata(fsdata->record[i]->name)) { continue; } for (int p = 0; prefix[p] != NULL; p++) { - if (find_in_file(fsdata->files[i], prefix[p]) == 0) { + if (find_in_file(fsdata->record[i]->name, prefix[p]) == 0) { int proceed = 0; if (mode == PREFIX_WRITE_BIN) { - proceed = file_is_binary(fsdata->files[i]); + proceed = file_is_binary(fsdata->record[i]->name); } else if (mode == PREFIX_WRITE_TEXT) { - proceed = file_is_text(fsdata->files[i]); + proceed = file_is_text(fsdata->record[i]->name); } // file_is_* functions return NULL when they encounter anything but a regular file @@ -332,7 +335,7 @@ int prefixes_write(const char *output_file, int mode, char **prefix, const char continue; } // Record in file - fprintf(fp, "#%s\n%s\n", prefix[p], fsdata->files[i]); + fprintf(fp, "#%s\n%s\n", prefix[p], fsdata->record[i]->name); } } } |