Making a New Directory

A C/C++ program may create a directory by calling upon the UNIX mkdir(2) system call. Its synopsis is as follows:

#include <sys/types.h>
#include <sys/stat.h>

int mkdir(const char *path, mode_t mode);

The argument path is the pathname of the new directory that is to be created. All intermediate directory names in the pathname must already exist. Only the last component of the pathname is actually created. The argument mode specifies the permission bits that are to be given to the new directory being created. In most cases, the S_ISGID, S_ISUID, and S_ISVTX bits are silently deleted from the value given in mode. The final permission bits assigned to the new directory are affected by applying the current umask(2) setting. ...

Get Advanced UNIX Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.