std/storage/file
std/storage/src/file.trb
FileStorage: the driver of file:, over std/fs.
type FileStorage
shared type FileStorage with Storage
file: - the local disk, through std/fs. A reference is a file: URI of RFC 8089 (file:///srv/data/index,
file:///C:/data/index), read as a Path and handed to std/fs in its text form.
- A write replaces the file whole or not at all (
File.writeBytesAtomically), and creates the directories above it, so a reader - or the program after a crash - never finds half of what was written. - A read runs on the blocking pool (
File.read), so a large file does not stop the worker it was asked on. - A directory is listed with the references of its entries, and deleting one deletes everything in it; a symbolic link inside is removed and never followed.
Examples
fn settings(): Task<Result<String, StorageFailure>> {
const storage = FileStorage()
storage.readText("file:///etc/hostname").await()
}
fn schemes
fn schemes(): List<String>
Not documented.
fn read
fn read(uri: Uri): Task<Result<Bytes, StorageFailure>>
Not documented.
fn exists
fn exists(uri: Uri): Task<Result<Bool, StorageFailure>>
Not documented.
fn list
fn list(uri: Uri): Task<Result<List<Uri>, StorageFailure>>
Not documented.
fn write
var fn write(uri: Uri, content: Bytes): Task<Result<Void, StorageFailure>>
Not documented.
fn delete
var fn delete(uri: Uri): Task<Result<Void, StorageFailure>>
Not documented.