rmdir

Removes (deletes) the specified directory.

Library:LibC
Classification:POSIX
Service:File and Directory I/O

Syntax

  #include <unistd.h> 
   
  int rmdir (
     const char   *path);
  

Parameters

path

(IN) Specifies the path to the directory to delete.

Return Values

If successful, returns 0. Otherwise, returns -1 and sets errno to one of the following:

Decimal

Constant

Description

1

ENOENT

The path parameter either names a nonexistent directory or points to an empty string.

6

EACCES

The requester is lacking search permissions on a component of the path parameter or write permissions to the parent directory.

7

EEXIST

The directory specified by the path parameter is not empty.

9

EINVAL

The path parameter contains an invalid value.

28

EIO

A physical I/O error has occurred.

62

EBUSY

The directory is currently in use by the system or some other process.

65

ENAMETOOLONG

The length of the path parameter exceeds the maximum path length, or a component in the path parameter is longer than the maximum length for a component.

67

ENOTDIR

A component in the path parameter is not a directory.

68

ENOTEMPTY

The directory specified by the path parameter is not empty.

76

EROFS

The specified directory resides on a read-only file system.

Remarks

The directory can be removed only if it is empty and does not contain any files or directories.

See Also