createParentDirectories

Ensures that all parent directories of this path exist, creating them if required.

If the parent directory already exists, this function does nothing.

Note that the parent directory is not always the directory that contains the entry specified by this path. For example, the parent of the path x/y/. is x/y, which is logically the same directory, and the parent of x/y/.. (which means just x/) is also x/y. Use the function Path.normalize to eliminate redundant name elements from the path.

Since Kotlin

1.9

Return

this path unchanged if all parent directories already exist or have been created successfully.

Parameters

attributes

an optional list of file attributes to set atomically when creating the missing parent directories.

See also

Throws

if there is already a file located by the parent path or one of its parent paths (optional specific exception, some implementations may throw more general IOException).

if an I/O error occurs.

if the attributes array contains an attribute that cannot be set atomically when creating the directory.