Skip to content

cf_fs_enumerate_directory

Category: file
GitHub: cute_file_system.h


Returns a sorted list of files and directories in the given directory.

const char** cf_fs_enumerate_directory(const char* virtual_path);
Parameters Description
virtual_path The virtual path to the directory.

Return Value

Returns any errors as a CF_Result.

Code Example

Loop over a list of all files in a directory.

const char list = cf_fs_enumerate_directory("/data");
for (const char i = list; i; ++i) {
    printf("Found %s\n", i);
}
cf_fs_free_enumerated_directory(list);

Remarks

Results are collected by visiting the search path for all real directories mounted on virtual_path. No duplicate file names will be reported. The list itself is sorted alphabetically, though you can further sort it however you like. Free the list up with cf_fs_free_enumerated_directory when done. The final element of the list is NULL. Virtual File System.

cf_fs_remove_directory
cf_fs_create_directory
cf_fs_free_enumerated_directory