DirRemove
Description
Remove an empty directory. Direct syscall (rmdir on Linux x86_64 / Darwin, unlinkat(... AT_REMOVEDIR) on Linux aarch64, RemoveDirectoryA on Windows). The directory must be empty; populated directories require recursive removal via DirRemoveAll.
Parameters
| Name | Direction | Description |
|---|---|---|
path |
in | Path of the directory. Prefer Str *; Zstr accepted. |
Success
Returns 1; the directory is gone.
Failure
Returns 0; logs the failing syscall.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Dir.c:371:
i8 dir_remove(Zstr path) {
if (!path) {
LOG_FATAL("DirRemove: NULL path");
}
#if PLATFORM_WINDOWS- In
Dir.c:375:
#if PLATFORM_WINDOWS
if (!RemoveDirectoryA(path)) {
LOG_ERROR("DirRemove(\"{}\"): RemoveDirectoryA failed (GetLastError={})", path, (i32)GetLastError());
return 0;
}- In
Dir.c:389:
# endif
if (ret < 0) {
LOG_SYS_ERROR(ErrnoOf(ret), "DirRemove(\"{}\")", path);
return 0;
}- In
Dir.c:395:
#else
# error \
"DirRemove: no direct-syscall path. Add MISRA_SYS_rmdir / MISRA_SYS_unlinkat numbers in _Syscall.h for this arch."
#endif
}- In
Dir.c:576:
return 0;
}
return DirRemove(path);
}
Last updated on