mkdir

mkdir — creates a new sub-directory.

Syntax

mkdir (dirname, mode)

		

Arguments

dirname

The name of the directory to create.

mode

The access permissions of the new directory, joined in sequence. If there are more than one, they are OR'ed by the | character in text format, or written consecutively in octal format. (See below.)

Returns

Zero if successful, otherwise non-zero, and the errno will be set.

Description

This function creates a new sub-directory whose path-name is dirname. The file permissions for the new sub-directory are determined from the mode argument. Valid modes are summarized here.

Table 12. User/owner permission modes

Text formatOctal formatMeaning
S_IRWXU0o7Read, write, execute/search
S_IRUSR0o4Read permission
S_IWUSR0o2Write permission
S_IXUSR0o1Execute/search permission

Table 13. Group permission modes

Text formatOctal formatMeaning
S_IRWXG0o7Read, write, execute/search
S_IRGRP0o4Read permission
S_IWGRP0o2Write permission
S_IXGRP0o1Execute/search permission

Table 14. Other permission modes

Text formatOctal formatMeaning
S_IRWXO0o7Read, write, execute/search
S_IROTH0o4Read permission
S_IWOTH0o2Write permission
S_IXOTH0o1Execute/search permission

Miscellaneous permissions.

    S_IREAD same as S_IRUSR

    S_IWRITE same as S_IWUSR

    S_IEXEC same as S_IXUSR

These flags are bitwise OR-ed together to get the desired mode.

Error constants for this function:

    EACCES Search permission for some component of the path denied.

    EEXIST The named file exists.

    EMLINK Maximum sub-dirs. reached.

    ENAMETOOLONG The name of the path or the new directory is too long.

    ENOENT The specified path does not exist.

    ENOSPC No space left on the file system.

    ENOSYS This function is not supported for this path.

    ENOTDIR A component of the passed path is not a directory.

    EROFS Tried to create a directory on a read-only file system.

Example

Gamma> require_lisp("const/Filesys");
"/usr/cogent/lib/const/Filesys.lsp"
Gamma> mkdir("/tmp/mydir", S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH);
0
Gamma> mkdir("/tmp/mydir2", 0o755);
0
Gamma> 
		

See Also

unlink