Section 14.3. Creating and Removing Directories

   


14.3. Creating and Removing Directories

14.3.1. Creating New Directories

Creating new directories is straightforward.

 #include <fcntl.h> #include <unistd.h> int mkdir(const char * dirname, mode_t mode); 


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.


       
    top
     


    Linux Application Development
    Linux Application Development (paperback) (2nd Edition)
    ISBN: 0321563220
    EAN: 2147483647
    Year: 2003
    Pages: 168

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net