File

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

A File

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

Constructors

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

Properties

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

absolutePath but returns a file

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

Returns the absolute pathname string of this abstract pathname.

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

The name of the file or directory. The last segment of the path.

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

The path parent. If no parent is available, null is returned.

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

The path parent. If no parent is available, null is returned.

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 = "canonicalFileOf")
fun File.canonicalFile(): File

canonicalPath but returns a file

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

Returns the canonical pathname string of this abstract pathname.

Link copied to clipboard
fun chmod(mode: String)

Changes POSIX file/directory permissions.

Link copied to clipboard
expect fun delete(): Boolean

Deletes the file or directory denoted by this abstract pathname.

actual fun delete(): Boolean
Link copied to clipboard
expect fun exists(): Boolean

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

actual fun exists(): Boolean
Link copied to clipboard
inline fun <T> File.fOpen(flags: String, block: (file: CPointer<FILE>) -> T): T

Opens the File, closing it automatically once block completes.

Link copied to clipboard
expect fun isAbsolute(): Boolean

Tests whether this abstract pathname is absolute.

actual fun isAbsolute(): Boolean
Link copied to clipboard
Link copied to clipboard
expect fun mkdir(): Boolean

Creates the directory named by this abstract pathname.

actual fun mkdir(): Boolean
Link copied to clipboard
expect fun mkdirs(): Boolean

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.

actual fun mkdirs(): Boolean
Link copied to clipboard
@JvmName(name = "normalizedFileOf")
fun File.normalize(): File

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

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

Read the full contents of the file (as bytes).

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

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

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

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

fun File.resolve(relative: String): File
Link copied to clipboard
fun File.stat(): Stats
Link copied to clipboard
fun File.write(data: Buffer)
Link copied to clipboard
@JvmName(name = "writeBytesTo")
fun File.writeBytes(array: ByteArray)

Writes the full contents of array to the file

Link copied to clipboard
@JvmName(name = "writeUtf8To")
fun File.writeUtf8(text: String)

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