ReadOnly

Defines a read-only interface that combines the functionalities of serialization, file selection, and file reading in a file system or comparable data structure.

Parameters

Path

Represents the type of the path used to reference files or directories.

This interface inherits methods from the following:

  • Serialization: Serialization and deserialization of file paths into string representations.

  • Select: Operations to fetch metadata, list contents, navigate parent directories, and check existence.

  • Read: Functionality to read file content, access file content as a source, and determine file size.

Implementers of this interface are expected to provide implementations for all functionality associated with serialization, selection, and reading, ensuring a complete read-only perspective of the file system or equivalent storage mechanisms.

This interface is useful in scenarios where modification operations are either undesired or disallowed, offering controlled access to an underlying file or directory structure.

Inheritors

Functions

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 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 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.