FileService

interface FileService(source)

Abstracts file system operations (like reading from or writing to URIs) so that ViewModels can remain platform-independent.

Functions

Link copied to clipboard
abstract suspend fun read(uri: CommonUri, block: suspend (BufferedSource) -> Unit): Boolean

Opens a file or URI for reading and provides a BufferedSource. The source is automatically closed after block execution. Returns true if successful, false otherwise.

Link copied to clipboard
abstract suspend fun write(uri: CommonUri, block: suspend (BufferedSink) -> Unit): Boolean

Opens a file or URI for writing and provides a BufferedSink. The sink is automatically closed after block execution. Returns true if successful, false otherwise.