FAT | RFS | XFS
rmdir()
PROTOTYPE
#include <posix.h>
int rmdir(const char *path);
DESCRIPTION
rmdir() removes the directory specified by path, which cannot end with “.” or “..”. Paths starting with ‘/’ are absolute. Otherwise they are relative to the CWD.
rmdir() fails with errno set to ENOTEMPTY if used on a non-empty directory. It fails with errno set to EBUSY if the directory is either open, a root directory, or any task’s CWD.
The caller needs execute-access to every directory in the path prefix and write-access to the parent directory. The parent directory’s status change and data modification timestamps are updated.
If successful, rmdir() returns 0. Otherwise, it sets errno and returns -1.
ERROR CODES
| EACCES | No execute access to a directory in the path prefix or no write access to the parent directory. |
| EBUSY | The specified directory is either open, a root directory, or a task’s CWD. |
| EFAULT | path equals NULL. |
| EINVAL | path ends with “.” or “..”. |
| ENAMETOOLONG | A name in path exceeds the effective maximum file name length. |
| ENOENT | path is the empty string or includes a directory that was not found. |
| ENOTDIR | One of the path components is not a directory. |
| ENOTEMPTY | The directory specified by path is not empty. |
| EROFS | The volume is read-only. |
EXAMPLE
/*---------------------------------------------------------------*/
/* Remove the named directory. */
/*---------------------------------------------------------------*/
if (rmdir(path1))
perror("rmdir() failed");