12.12. Creating a directory

[<<<] [>>>]

Although the OPEN statement automatically creates the directory for the file whenever you want to create a new file you may want to create a directory without creating a file in it. For the purpose the statement mkdir can be used. The syntax of the command is very simple:

mkdir expression

The expression should result a string, which is the directory to be created. The command recursively creates the directories that do not exist by the time the command is executed and need creation in order to create the final directory. For example you can issue the command

mkdir "/usr/bin/scriba"

without issuing the commands

mkdir "/usr"
mkdir "/usr/bin"

The directories `/usr' and `/usr/bin' are automatically created in the unlikely case they did not exist.

The command executes without error if the directory is created or if the directory already existed. If the directory can not be created an error occurs. The reason for directory creation failure can be numerous. The most typical is access control prohibiting for the process directory creation. Another usual problem is when some sub-path of the desired directory already exists, but is a file. For example we want to create the directory /usr/bin/scriba/exe and /usr/bin/scriba already exists and is a plain file.


[<<<] [>>>]