fun Path.createParentDirectories(
    vararg attributes: FileAttribute<*>
): Path


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.


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


FileAlreadyExistsException - 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).

IOException - if an I/O error occurs.

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

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

See Also