Skip to content

DirContents

Description

Vector type for directory contents.

Usage example (Cross-references)

Usage examples (Cross-references)
    #ifdef _WIN32
    // Windows-specific implementation using FindFirstFile/FindNextFile
    DirContents DirGetContents(const char *path, Allocator *alloc) {
        if (!path || !alloc) {
            LOG_FATAL("Invalid argument");
        }
    
        DirContents dc = (DirContents)VecInit(alloc);
    
        // Construct the search path with a wildcard
    #else
    // APPLE or Unix based system implementation using opendir/readdir
    DirContents DirGetContents(const char *path, Allocator *alloc) {
        if (!path || !alloc) {
            LOG_FATAL("invalid arguments.");
        }
    
        DirContents dc = (DirContents)VecInit(alloc);
    
        DIR *dir = opendir(path);
    /// TAGS: System, FileSystem, Directory
    ///
    DirContents DirGetContents(const char *path, Allocator *alloc);
    
    ///
            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