File

expect class File(pathname: String) : Comparable<File> (source)

A File which holds the abstract pathname to a location on the filesystem, be it for a regular file, directory, symbolic link, etc.

actual typealias File = java.io.File(source)
actual class File(pathname: String) : Comparable<File> (source)

A File which holds the abstract pathname to a location on the filesystem, be it for a regular file, directory, symbolic link, etc.

Constructors

Link copied to clipboard
expect constructor(pathname: String)
actual constructor(pathname: String)

Properties

Link copied to clipboard
@get:JvmName(name = "nameOf")
val File.name: String

The name of the file or directory.

Link copied to clipboard
@get:JvmName(name = "parentFileOf")
val File.parentFile: File?

The path parent File.

Link copied to clipboard
@get:JvmName(name = "parentPathOf")
val File.parentPath: String?

The path parent.

Link copied to clipboard
@get:JvmName(name = "pathOf")
val File.path: String

The abstract path to a directory or file.

Functions

Link copied to clipboard
@JvmName(name = "absoluteFile2Of")
fun File.absoluteFile2(): File

If this abstract pathname is already absolute, then the pathname File is simply returned.

Link copied to clipboard
@JvmName(name = "absolutePath2Of")
fun File.absolutePath2(): String

If this abstract pathname is already absolute, then the pathname string is simply returned.

Link copied to clipboard
inline fun File.append(excl: OpenExcl?, data: Buffer)

Writes the contents of a Buffer to the file associated with the abstract pathname. If the file exists, all new data will be appended to the end of the file.

Link copied to clipboard
@JvmName(name = "appendBytesTo")
inline fun File.appendBytes(excl: OpenExcl?, array: ByteArray): File

Writes the full contents of array to the file. If the file exists, all new data will be appended to the end of the file.

Link copied to clipboard
@JvmName(name = "appendUtf8To")
inline fun File.appendUtf8(excl: OpenExcl?, text: String): File

Writes the full contents of text to the file. If the file exists, all new text will be appended to the end of the file.

Link copied to clipboard
@JvmName(name = "canonicalFile2Of")
fun File.canonicalFile2(): File

A canonical pathname is both absolute and unique. The precise definition of canonical form is system-dependent.

Link copied to clipboard
@JvmName(name = "canonicalPath2Of")
fun File.canonicalPath2(): String

A canonical pathname is both absolute and unique. The precise definition of canonical form is system-dependent.

Link copied to clipboard
@JvmOverloads
fun File.chmod2(mode: String, mustExist: Boolean = true): File

Modifies file or directory permissiveness.

Link copied to clipboard
expect open operator override fun compareTo(other: File): Int
actual open operator override fun compareTo(other: File): Int
Link copied to clipboard
@JvmOverloads
fun File.delete2(ignoreReadOnly: Boolean = false, mustExist: Boolean = false): File

Deletes the file or directory denoted by this abstract pathname.

Link copied to clipboard
fun File.exists2(): Boolean

Tests whether the file or directory denoted by this abstract pathname exists.

Link copied to clipboard
expect fun isAbsolute(): Boolean

Tests whether this abstract pathname is absolute.

actual fun isAbsolute(): Boolean

Tests whether this abstract pathname is absolute.

Link copied to clipboard

Retrieve the symbolic Stats referred to by the abstract pathname.

Link copied to clipboard
@JvmOverloads
fun File.mkdir2(mode: String?, mustCreate: Boolean = false): File

Creates the directory named by this abstract pathname.

Link copied to clipboard
@JvmOverloads
fun File.mkdirs2(mode: String?, mustCreate: Boolean = false): File

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.

Link copied to clipboard

Removes all . and resolves all possible .. for the provided path.

Link copied to clipboard

Opens a File for write operations, appending all new data to the end of the file.

Link copied to clipboard

Opens a File for read operations.

Link copied to clipboard

Opens a File for read/write operations. The File is not truncated if it already exists, and the initial FileStream.position is 0.

Link copied to clipboard

Opens a File for write operations. The File will be truncated if it exists.

fun File.openWrite(excl: OpenExcl?, appending: Boolean): FileStream.Write

Opens a File for write operations.

Link copied to clipboard

Reads the entire content of a file associated with the abstract pathname into a Buffer.

Link copied to clipboard
@JvmName(name = "readBytesFrom")
fun File.readBytes(): ByteArray

Read the entire contents of a File (as bytes).

Link copied to clipboard
@JvmName(name = "readUtf8From")
fun File.readUtf8(): String

Read the entire contents of a File (as UTF-8 text).

Link copied to clipboard
fun File.resolve(relative: File): File
fun File.resolve(relative: String): File

Resolves the File for provided relative. If relative is absolute, returns relative, otherwise will concatenate the File.paths.

Link copied to clipboard
fun File.stat(): Stats

Retrieve the Stats referred to by the abstract pathname.

Link copied to clipboard
inline fun File.write(excl: OpenExcl?, data: Buffer)

Writes the contents of a Buffer to the file associated with the abstract pathname. The File will be truncated if it exists.

fun File.write(excl: OpenExcl?, appending: Boolean, data: Buffer)

Writes the contents of a Buffer to the file associated with the abstract pathname.

Link copied to clipboard
@JvmName(name = "writeBytesTo")
inline fun File.writeBytes(excl: OpenExcl?, array: ByteArray): File

Writes the full contents of array to the file. The File will be truncated if it exists.

@JvmName(name = "writeBytesTo")
fun File.writeBytes(excl: OpenExcl?, appending: Boolean, array: ByteArray): File

Writes the full contents of array to the file.

Link copied to clipboard
@JvmName(name = "writeUtf8To")
inline fun File.writeUtf8(excl: OpenExcl?, text: String): File

Writes the full contents of text to the file (as UTF-8). The File will be truncated if it exists.

@JvmName(name = "writeUtf8To")
fun File.writeUtf8(excl: OpenExcl?, appending: Boolean, text: String): File

Writes the full contents of text to the file (as UTF-8).