# create_directory

Definition: | bool res = create_directory(string name, integer mode=0o700, bool make_parent=true)
Description: | Create a new directory. name: the name of the new directory to create. mode: on Unix systems, permissions for the new directory. Default is 0o700 (all rights for owner, none for others). make_parent: when true (the default) the parent directories are also created as needed. Returns: false (0) on failure, true (1) on success.
pwa/p2js: | Not supported.
Comments: | mode is ignored on non-Unix platforms. Both forwardslash ('/') and backslash ('\\') are handled for all platforms. A trailing slash is optional on directories, it makes no difference whether one is present or not. The use of a named parameter when setting make_parent is recommended, to make the intent clear and the code easier to read.
Example: |
    if not create_directory("backup") then
        crash("Filesystem problem - could not create backup folder")
    end if

    -- This example will also create "myapp/" and "myapp/interface/" if they do not exist.
    if not create_directory("myapp/interface/letters") then
        crash("Filesystem problem - could not create the new folder")
    end if

    -- This example will NOT create "myapp/" and "myapp/interface/" if they do not exist.
    if not create_directory("myapp/interface/letters",make_parent:=false) then
        crash("Filesystem problem - could not create the new folder")
    end if
Implementation: | See builtins\pfile.e (an autoinclude) for details of the actual implementation.
See Also: | remove_directory, chdir