Write

Provides functionalities for creating, moving, writing, and deleting files or directories while maintaining a serialization context.

This interface is designed to interact with a file system hierarchy in a structured way, allowing operations to manage file content and metadata effectively.

Parameters

Path

A type representing a file system location.

Inheritors

Functions

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

Creates a new file or directory within a specified parent directory.

Link copied to clipboard
abstract suspend fun delete(parent: Path, name: String)

Deletes a child file or directory with the specified name from the parent directory.

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

Retrieves the file extension from the specified path.

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

Converts a string representation of an absolute file path into a Path object.

Link copied to clipboard
abstract fun fromRelativeString(base: Path, path: String): Path

Converts a relative path string to a Path object by resolving it against a base path.

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

Moves a file or directory from the source path to the target path.

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

Retrieves the name of the file or directory represented by the given path.

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

Creates and returns a Sink for the given path. The Sink can be used to write data to the file or directory represented by the specified path.

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

Converts a given Path object into its absolute path representation as a string.

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

Converts the given path to a string representation of the file path.

Link copied to clipboard
abstract suspend fun write(path: Path, content: ByteArray)

Writes the specified content to the given path.