DirGetContents
Description
Read directory contents into a vector. Current contents of the vector will be cleared out.
Parameters
| Name | Direction | Description |
|---|---|---|
path |
in | Path of directory get content of. |
alloc |
in | Allocator used to back the returned vector and entry names. |
Success
DirContents vector filled with directory contents data.
Failure
Returns empty vector on read error.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Dir.c:73:
#ifdef _WIN32
// Windows-specific implementation using FindFirstFile/FindNextFile
DirContents DirGetContents(const char *path, Allocator *alloc) {
if (!path || !alloc) {
LOG_FATAL("Invalid argument");- In
Dir.c:119:
#else
// APPLE or Unix based system implementation using opendir/readdir
DirContents DirGetContents(const char *path, Allocator *alloc) {
if (!path || !alloc) {
LOG_FATAL("invalid arguments.");- In
MisraDoc.c:214:
Str *dir_name = &dir_paths.data[i];
DirContents dir_contents = DirGetContents(dir_name->data, &alloc.base);
VecForeach(&dir_contents, dir_entry) {
if (dir_entry.type == SYS_DIR_ENTRY_TYPE_DIRECTORY) {
Last updated on