ReadWrite

This is the most comprehensive interface, offering complete filesystem operations including reading, writing, and path manipulation.

Inheritors

Functions

Link copied to clipboard
abstract suspend fun copy(source: Path, target: Path)

Copies a file or directory from source to target. If the source is a directory, all its contents are copied recursively. Parent directories of the target will be created if they don't exist.

Link copied to clipboard
abstract suspend fun create(path: Path, type: FileMetadata.FileType)

Creates a new file or directory denoted by the path using the specified type. Parent directories will be created if they don't exist.

Link copied to clipboard

Creates a directory at the specified path. Parent directories will be created automatically if they don't exist.

Link copied to clipboard

Creates a file at the specified path. Parent directories will be created automatically if they don't exist.

Link copied to clipboard
abstract suspend fun delete(path: Path)

Deletes a file or directory denoted by the path. If the item is a directory, it will be deleted recursively with all its contents.

Link copied to clipboard
abstract suspend fun exists(path: Path): Boolean

Checks if a path exists in the filesystem.

Link copied to clipboard
abstract fun extension(path: Path): String

Gets the extension of a path. This method works with the path structure and doesn't check if the path actually exists in the filesystem.

Link copied to clipboard

Filters the current read-only file system implementation such that only paths that are accepted by filter are visible and accessible.

Filters the current read-write file system implementation such that only paths that are accepted by filter are visible and accessible.

Link copied to clipboard
abstract fun fromAbsolutePathString(path: String): Path

Creates a Path object from an absolute path string. This method works with the path structure and doesn't check if the path actually exists in the filesystem.

Link copied to clipboard

Detects the type of content stored in a file using a path.

Link copied to clipboard
abstract suspend fun inputStream(path: Path): Source

Creates a Source for reading from a file at the specified path. The returned Source is buffered.

Link copied to clipboard
abstract fun joinPath(base: Path, vararg parts: String): Path

Resolves strings from parts against a base path. This method works with the path structure and doesn't check if the path actually exists in the filesystem.

Link copied to clipboard
abstract suspend fun list(directory: Path): List<Path>

Lists contents of a directory. Children are sorted by name. The listing is not recursive.

Link copied to clipboard
abstract suspend fun metadata(path: Path): FileMetadata?

Retrieves metadata for a file or directory using a path.

Link copied to clipboard
abstract suspend fun move(source: Path, target: Path)

Moves a file or directory from source to target. If the source is a directory, all its contents are moved recursively. Parent directories of the target will be created if they don't exist.

Link copied to clipboard
abstract fun name(path: Path): String

Gets the name component of a path. This method works with the path structure and doesn't check if the path actually exists in the filesystem.

Link copied to clipboard
abstract suspend fun outputStream(path: Path, append: Boolean = false): Sink

Creates a Sink for writing to a file. If the file doesn't exist, it will be created. If the parent directories don't exist, they will be created. The returned Sink is buffered.

Link copied to clipboard
abstract fun parent(path: Path): Path?

Gets the parent path of a given path. This method works with the path structure and doesn't check if the path actually exists in the filesystem.

Link copied to clipboard
abstract suspend fun readBytes(path: Path): ByteArray

Reads the content of a file at the specified path.

Link copied to clipboard

Reads the entire content of a file as a string.

Link copied to clipboard
abstract fun relativize(root: Path, path: Path): String?

Computes the relative path from a root to a target path. It doesn't check if the paths actually exist in the filesystem.

Link copied to clipboard
abstract suspend fun size(path: Path): Long

Gets the size of a file in bytes.

Link copied to clipboard
abstract fun toAbsolutePathString(path: Path): String

Converts a path to its absolute path string representation. This method works with the path structure and doesn't check if the path actually exists in the filesystem.

Link copied to clipboard
abstract suspend fun writeBytes(path: Path, data: ByteArray)

Writes content to a file. If the file doesn't exist, it will be created. If the file exists, its content will be overwritten. Parent directories will be created if they don't exist.

Link copied to clipboard
suspend fun <Path> FileSystemProvider.ReadWrite<Path>.writeText(path: Path, content: String)

Writes a string to a file, replacing any existing content.