ModelFileSystem

Minimal blocking file-system API used by the model manager. Paths are platform paths: / separated on every supported platform, and \ separated too on Windows. Call it from an I/O dispatcher.

defaultModelFileSystem returns the platform implementation (java.io/java.nio on Android and JVM, POSIX on iOS); tests use an in-memory fake.

Inheritors

Functions

Link copied to clipboard
abstract fun atomicMove(source: String, target: String)

Moves source to target, replacing target. Atomic when both are on the same volume, so readers never see a partially written target.

Link copied to clipboard
abstract fun createDirectories(path: String)

Creates path and any missing parent directories.

Link copied to clipboard

Deletes the file at path. Returns false if it did not exist.

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

Whether a file or directory exists at path.

Link copied to clipboard
abstract fun lastModifiedMillis(path: String): Long

Last modification time in epoch milliseconds, or 0 if unknown.

Link copied to clipboard
abstract fun list(directory: String): List<String>

Names (not paths) of the regular files directly inside directory; empty if it does not exist.

Link copied to clipboard
abstract fun openAppend(path: String, truncate: Boolean = false): FileSink

Opens path for appending, creating it if needed; with truncate it is emptied first.

Link copied to clipboard
abstract fun openRead(path: String): ModelByteSource

Opens path for random-access reading.

Link copied to clipboard
abstract fun size(path: String): Long

Size of the regular file at path in bytes, or -1 if it does not exist.