FilesystemGateway

Sandboxed multiplatform file-system gateway.

All paths are interpreted relative to the gateway's base path. Implementations MUST reject attempts to escape the sandbox via .. or absolute paths.

Methods are suspend so I/O can be dispatched off the calling coroutine where appropriate.

Inheritors

Functions

Link copied to clipboard
abstract suspend fun createDirectory(path: String)

Create path (and any missing parents) inside the sandbox.

Link copied to clipboard
abstract suspend fun findFilesByGlob(path: String, pattern: String): List<String>

Find every file under path whose relative path matches the glob pattern.

Link copied to clipboard
abstract suspend fun findFilesContaining(path: String, pattern: String): List<String>

Find every text file under path whose contents match the regex pattern.

Link copied to clipboard
abstract suspend fun findLinesMatching(path: String, fileName: String, pattern: String): List<LineMatch>

Find every line in path/fileName whose content matches pattern.

Link copied to clipboard
abstract suspend fun listAllFiles(path: String): List<String>

Recursive listing of every file under path (relative paths).

Link copied to clipboard
abstract suspend fun ls(path: String): List<String>

Non-recursive listing of path (paths returned relative to the base).

Link copied to clipboard
abstract suspend fun read(path: String, fileName: String): String

Read the full UTF-8 text contents of path/fileName.

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

Replace the contents of path/fileName with content (UTF-8).