Skip to content

DirEntry

Description

Directory entry structure containing type and name.

Usage example (Cross-references)

Usage examples (Cross-references)
        DirEntryType type;
        Str          name;
    } DirEntry;
    
    ///
    /// TAGS: System, Directory, Structure, Copy
    ///
    DirEntry *DirEntryInitCopy(DirEntry *dst, const DirEntry *src);
    
    ///
    /// TAGS: System, Directory, Structure, Cleanup
    ///
    DirEntry *DirEntryDeinitCopy(DirEntry *copy);
    
    ///
    /// Vector type for directory contents.
    ///
    typedef Vec(DirEntry) DirContents;
    
    // Path-arg dispatch. Library design: `Str *` is the canonical path
    }
    
    DirEntry *DirEntryInitCopy(DirEntry *dst, const DirEntry *src) {
        if (!dst || !src) {
            LOG_FATAL("Invalid arguments");
    }
    
    DirEntry *DirEntryDeinitCopy(DirEntry *copy) {
        if (!copy) {
            LOG_FATAL("Invalid arguments");
                }
    
                DirEntry direntry = {0};
                // Determine file type based on attributes
                if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
                int is_dotdot = (name_len == 2) && (nm[0] == '.') && (nm[1] == '.');
                if (!is_dot && !is_dotdot) {
                    DirEntry direntry = {0};
                    direntry.type     = dirent_type_to_misra(de->d_type);
                    direntry.name     = StrInitFromCstr(nm, name_len, alloc);
        bool trail_sep = (path_len > 0 && path[path_len - 1] == '/');
        for (size i = 0; i < VecLen(&dc); ++i) {
            DirEntry *e        = VecPtrAt(&dc, i);
            Zstr      entry_nm = StrBegin(&e->name);
            if (ZstrCompare(entry_nm, ".") == 0 || ZstrCompare(entry_nm, "..") == 0) {
Last updated on