mkdirs2

@JvmOverloads
fun File.mkdirs2(mode: String?, mustCreate: Boolean = false): File(source)

Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails it may have succeeded in creating some of the necessary parent directories. In this event the implementation is such that it attempts to "clean up" any parent directories that it created, before throwing its exception.

Return

The File for chaining operations.

Parameters

mode

The permissions to set for the newly created directory and any necessary, but nonexistent parent directories that were created. Must be 3 digits, each being between 0 and 7 (inclusive). If null, default directory permissions 777 will be used.

mustCreate

If false, failure to create the directory due to it already existing on the filesystem will return safely, instead of throwing FileAlreadyExistsException. If true, then the FileAlreadyExistsException will be thrown. Default false.

See also

Throws

IllegalArgumentException

if mode is inappropriate.

If there was a failure to create the directory, such as a parentPath points to a File that is not a directory, or the filesystem threw a security exception.

UnsupportedOperationException

On Kotlin/JS-Browser.