The path specified by dirname is created as a new directory with permissions mode (which is modified by the process's umask). If dirname specifies an existing file or if any of the elements of dirname are not a directory or a symbolic link to a directory, the system call fails.
14.3.2. Removing Directories
Removing a directory is almost exactly the same as removing a file; only the name of the system call is different.
#include <unistd.h> int rmdir(char * pathname);
For rmdir() to succeed, the directory must be empty (other than the omnipresent . and .. enTRies); otherwise, ENOTEMPTY is returned.