The name of the directory to create.
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.)
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 format | Octal format | Meaning |
|---|---|---|
| S_IRWXU | 0o7 | Read, write, execute/search |
| S_IRUSR | 0o4 | Read permission |
| S_IWUSR | 0o2 | Write permission |
| S_IXUSR | 0o1 | Execute/search permission |
Table 2. Group permission modes
| Text format | Octal format | Meaning |
|---|---|---|
| S_IRWXG | 0o7 | Read, write, execute/search |
| S_IRGRP | 0o4 | Read permission |
| S_IWGRP | 0o2 | Write permission |
| S_IXGRP | 0o1 | Execute/search permission |
Table 3. Other permission modes
| Text format | Octal format | Meaning |
|---|---|---|
| S_IRWXO | 0o7 | Read, write, execute/search |
| S_IROTH | 0o4 | Read permission |
| S_IWOTH | 0o2 | Write permission |
| S_IXOTH | 0o1 | Execute/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.
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.