Write

Singleton object that provides implementations for creating, moving, writing, and deleting files or directories, while adhering to a serialization context. It also ensures compatibility with specific operating system constraints such as Windows reserved names. Implements the FileSystemProvider.Write interface with Path as the path type and delegates serialization functionalities to a Serialization implementation.

Functions

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

Creates a new file or directory at the specified location.

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

Deletes a file or directory specified by the given parent path and name. The deletion is performed in an IO-optimized context. If the target is a directory, it will be deleted recursively.

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

Retrieves the file extension from the specified path.

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

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

Link copied to clipboard
open override 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
open suspend override fun move(source: Path, target: Path)

Moves a file or directory from the source path to the target path. If the source is a directory, all its contents are moved recursively. If the source is a file, it is moved directly to the target. Ensures operations are performed using IO dispatchers.

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

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

Link copied to clipboard
open suspend override fun sink(path: Path, append: Boolean): Sink

Creates and returns a Sink for the given file path, allowing data to be written to the file. It ensures that parent directories of the file path are created if they do not already exist. The operation is performed in the IO context.

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

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

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

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

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

Writes the provided content to the specified path. Ensures that any necessary parent directories for the path are created before writing the content.