Storage

interface Storage<Path>(source)

Core storage abstraction for the memory system that provides a unified interface for file operations across different platforms and storage backends.

Key features:

  • Platform-independent path handling

  • Basic file operations (read, write, exists)

  • Directory management

  • Null safety for missing files

Usage example:

val storage: Storage<Path> = SimpleStorage(fileSystem)
// or
val storage: Storage<Path> = EncryptedStorage(fileSystem, encryption)

// Write data
storage.write(path, "Important data")

// Read data
val data = storage.read(path)

Parameters

Path

Platform-specific path type (e.g., java.nio.file.Path for JVM)

Inheritors

Functions

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

Creates a directory and all parent directories if needed. This operation is idempotent and thread-safe.

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

Verifies the existence of a file or directory. This operation is atomic and thread-safe.

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

Retrieves the content of a file as a string. This operation is atomic and handles missing files gracefully.

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

Writes content to a file, creating it if necessary. This operation is atomic and ensures: