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 1. User/owner permission modes

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

Table 2. Group permission modes

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

Table 3. Other permission modes

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

Miscellaneous permissions.

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

Error constants for this function:

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 the Common: the Data Directory of the Controller Functions chapter (Tutorial Two) in the Cogent Tools Demo and Tutorials book for an example of this function used in context.

See Also

unlink

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.