Skip to content

DirRemoveAll

Description

Recursive rm -rf. Removes a directory tree (regular files, symlinks, subdirectories). If path doesn’t exist this is a no-op success. Follows the cross-platform i8 return convention.

Parameters

Name Direction Description
path in Root of the tree. Prefer Str *; const char * accepted.

Success

Returns 1; the path is gone (or never existed).

Failure

Returns 0 on first un-recoverable error.

Usage example (Cross-references)

Usage examples (Cross-references)
        FileRemove(bin_path);
        FileRemove(dsym_path);
        DirRemoveAll("/tmp/misra_macho_stripped.dSYM");
        return ok;
    }
        FileRemove(bin_path);
        FileRemove(dsym_path);
        DirRemoveAll("/tmp/misra_macho_uuidmiss.dSYM");
        return ok;
    }
    i8 dir_remove_all(Zstr path) {
        if (!path) {
            LOG_FATAL("DirRemoveAll: NULL path");
        }
        // Stat first: a missing path is a successful no-op (mirrors
                StrAppendFmt(&child, trail_sep ? "{}{}" : "{}/{}", path, e->name.data);
                if (e->type == SYS_DIR_ENTRY_TYPE_DIRECTORY) {
                    inner_ok = DirRemoveAll(&child);
                } else {
                    inner_ok = FileRemove(&child);
Last updated on