summaryrefslogtreecommitdiff
path: root/filesystem.h
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-12-24 00:28:50 -0500
committerpommicket <pommicket@gmail.com>2022-12-24 00:28:50 -0500
commit1c346f2aba30fcb581f20f2b67bd5e6adcb4a7e6 (patch)
tree863b8ebbd37c67cb4dd0015d5c72a436dd89bc7e /filesystem.h
parent8d96a4b0f0ebb059a63cc4c3193e0169ccf4f5b5 (diff)
find build directory in a much better way
this will be useful for LSPs
Diffstat (limited to 'filesystem.h')
-rw-r--r--filesystem.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/filesystem.h b/filesystem.h
index be57323..0c18494 100644
--- a/filesystem.h
+++ b/filesystem.h
@@ -25,7 +25,7 @@ FsPermission fs_path_permission(char const *path);
// Does this file exist? Returns false for directories.
bool fs_file_exists(char const *path);
// Returns a NULL-terminated array of the files/directories in this directory, or NULL if the directory does not exist/out of memory.
-// When you're done with the entries, call free on each one, then on the array.
+// When you're done with the entries, call fs_dir_entries_free (or call free on each entry, then on the whole array).
// NOTE: The files/directories aren't returned in any particular order!
FsDirectoryEntry **fs_list_directory(char const *dirname);
// Create the directory specified by `path`
@@ -41,6 +41,11 @@ int fs_mkdir(char const *path);
// -1 if we can't get the cwd for whatever reason.
int fs_get_cwd(char *buf, size_t buflen);
+void fs_dir_entries_free(FsDirectoryEntry **entries) {
+ for (int i = 0; entries[i]; ++i)
+ free(entries[i]);
+ free(entries);
+}
#endif // FILESYSTEM_H_