Files

object Files(source)

Reads and writes whole files on disk. Relative paths resolve against basePath, the directory that holds the running executable, so assets shipped next to the game are found wherever it is started from. Absolute paths are used as given.

Has no sample because it needs a file on disk.

Properties

Link copied to clipboard

Returns the directory that holds the running executable, ending with a path separator.

Functions

Link copied to clipboard

Returns whether path starts at a root: a leading slash or backslash, or a drive letter followed by a colon, as in C:. Such a path is used as given; any other path is relative and resolves against basePath.

Link copied to clipboard

Returns the contents of the file at path.

Link copied to clipboard

Returns the contents of the file at path, or null when the file does not exist, cannot be read, or is larger than Int.MAX_VALUE bytes.

Link copied to clipboard
fun readText(path: String): String

Returns the contents of the file at path decoded as UTF-8. Malformed byte sequences become the replacement character U+FFFD.

Link copied to clipboard

Returns the contents of the file at path decoded as UTF-8, or null when the file does not exist, cannot be read, or is larger than Int.MAX_VALUE bytes. Malformed byte sequences become the replacement character U+FFFD.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun writeBytes(path: String, bytes: ByteArray)

Writes bytes to the file at path, creating the file or replacing its contents. A directory on the way to the file that does not exist yet is created first, parents included.