ReadWrite

Represents a combined interface for read and write operations on a given pathway or resource.

This interface extends both the ReadOnly and Write interfaces, allowing full control over interacting with resources associated with a specific Path. This includes retrieval, modification, and creation operations. Suitable for cases where both read and write capabilities are required, without compromising the ability to manage the underlying resource effectively.

The ReadWrite interface inherits the contract of the following:

  • ReadOnly: Provides read-only access, including serialization, selection, and data retrieval operations.

  • Write: Enables data creation, modification, and deletion, supporting essential write-related functionality.

Parameters

Path

The type of the resource pathway or identifier handled by this interface.

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 exists(path: Path): Boolean

Checks if a given path exists in the file system.

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 list(path: Path): List<Path>

Lists all the paths under a specified directory or file path.

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

Retrieves the metadata associated with the specified file or directory.

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 parent(path: Path): Path?

Retrieves the parent directory/path of the given path.

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

Reads the content of the file at the specified path.

Link copied to clipboard
open suspend fun relative(root: Path, path: Path): String?

Computes the relative path from a given root path to the specified path.

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

Relativizes the given path path based on the specified root path. This function calculates the relative path from the root to the 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 suspend fun size(path: Path): Long

Retrieves the size of the file or directory at the specified path.

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

Provides access to a data source represented by the given 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.