SimpleStorage

Basic implementation of Storage that provides direct file system access without additional security layers. This implementation is suitable for non-sensitive data or when encryption is handled at a different level.

Key features:

  • Direct file system operations

  • UTF-8 encoding for text

  • Automatic directory creation

  • Thread-safe operations

Usage example:

val storage = SimpleStorage(JVMFileSystemProvider)

// Store configuration
storage.write(configPath, """
{
"setting1": "value1",
"setting2": "value2"
}
""".trimIndent())

// Read configuration
val config = storage.read(configPath)

Parameters

Path

Platform-specific path type

fs

File system provider for actual I/O operations

Constructors

Link copied to clipboard

Functions

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

Creates directory hierarchy with proper permissions. This operation is idempotent and ensures:

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

Verifies path existence in the file system. This is a lightweight operation that doesn't read file content.

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

Reads file content with UTF-8 decoding. This operation ensures proper handling of:

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

Writes content to a file with proper UTF-8 encoding. This operation ensures: