diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-12-06 08:26:35 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-12-06 08:26:35 -0500 |
commit | a2bcfc37f3634179b4e75fff38d4c36a1ab2a812 (patch) | |
tree | d8674978406c61d30b0c4f8693e8e967746c583a | |
parent | 2a15ece791252c07ddf2fe9868709bd80eecf489 (diff) | |
download | stasis-a2bcfc37f3634179b4e75fff38d4c36a1ab2a812.tar.gz |
Fix listdir()
* Now returns the absolute path(s) to the file(s)
* Remove restriction on reading hidden files
-rw-r--r-- | src/lib/core/utils.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lib/core/utils.c b/src/lib/core/utils.c index c03f8fa..aa4173c 100644 --- a/src/lib/core/utils.c +++ b/src/lib/core/utils.c @@ -766,7 +766,15 @@ struct StrList *listdir(const char *path) { if (!strcmp(rec->d_name, ".") || !strcmp(rec->d_name, "..")) { continue; } - strlist_append(&node, rec->d_name); + char *fullpath = join_ex("/", path, rec->d_name, NULL); + if (!fullpath) { + SYSERROR("%s", "Unable to allocate bytes to construct full path"); + guard_strlist_free(&node); + closedir(dp); + return NULL; + } + strlist_append(&node, fullpath); + guard_free(fullpath); } closedir(dp); return node; @@ -791,8 +799,6 @@ int mkdirs(const char *_path, mode_t mode) { char result[PATH_MAX] = {0}; int status = 0; while ((token = strsep(&path, "/")) != NULL && !status) { - if (token[0] == '.') - continue; strcat(result, token); strcat(result, "/"); status = mkdir(result, mode); |