DirRemove
Description
Remove an empty directory. Equivalent of POSIX rmdir(2) / Win32 RemoveDirectoryA. The directory must be empty; populated directories require recursive removal (callers can walk DirGetContents and remove entries one by one).
Return-type rationale matches FileRemove: i8 to sidestep the bool/_Bool cross-TU typedef hazard.
Parameters
| Name | Direction | Description |
|---|---|---|
path |
in | Path of the directory to remove. |
Success
Returns 1; the directory is gone.
Failure
Returns 0; logs the failing syscall. Common causes: directory doesn’t exist, directory is non-empty (ENOTEMPTY), no write permission on the parent directory.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Dir.c:451:
}
i8 DirRemove(const char *path) {
if (!path) {
LOG_ERROR("DirRemove: NULL path");- In
Dir.c:453:
i8 DirRemove(const char *path) {
if (!path) {
LOG_ERROR("DirRemove: NULL path");
return 0;
}- In
Dir.c:458:
#if defined(_WIN32)
if (!RemoveDirectoryA(path)) {
LOG_ERROR("DirRemove(\"{}\"): RemoveDirectoryA failed (GetLastError={})", path, (i32)GetLastError());
return 0;
}- In
Dir.c:472:
# endif
if (ret < 0) {
LOG_SYS_ERROR(SYS_ERRNO(ret), "DirRemove(\"{}\")", path);
return 0;
}- In
Dir.c:480:
extern int rmdir(const char *);
if (rmdir(path) != 0) {
LOG_SYS_ERROR(SYS_ERRNO(-1), "DirRemove(\"{}\")", path);
return 0;
}
Last updated on