FileInspector

interface FileInspector

Browses an app's own file storage. Every path is resolved against a fixed set of app-owned roots and canonicalized; anything escaping a root (.., symlinks, absolute paths) is refused. Text previews are redacted. Only regular files are ever touched -- never a directory tree -- across every operation here, including create/replace/rename. Every mutation (and readBytes, since it returns raw unredacted bytes) is ungated here -- callers (the Compose adapter in sdk:full, and the browser server routes in sdk:server-ktor) enforce the EditingCapabilities.files opt-in. Declared in sdk:server-api -- a plain boundary module with no Android dependency -- so both surfaces can share this one contract without a circular module dependency, the same way io.devconsole.state.SessionFeatureFlags reaches GET/POST /api/v1/flags.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun create(root: String, relativePath: String, content: String): Boolean

Writes a brand-new file with content. Refuses (false) when a file already exists there.

Link copied to clipboard
abstract fun delete(root: String, relativePath: String): Boolean
Link copied to clipboard
abstract fun list(root: String, relativePath: String): FileListingData?
Link copied to clipboard
abstract fun preview(root: String, relativePath: String): FilePreviewData
Link copied to clipboard
abstract fun readBytes(root: String, relativePath: String): ByteArray?

Raw, unredacted file bytes for download. Refuses (returns null) for a missing/inaccessible path, a directory, or a file larger than MAX_READ_BYTES so a debug download can never pull a multi-gigabyte file into memory.

Link copied to clipboard
abstract fun rename(root: String, relativePath: String, newRelativePath: String): Boolean

Moves a regular file to newRelativePath within the same root. Both the source and the destination are containment-checked; refuses (false) if the destination already exists so a rename can never silently clobber another file.

Link copied to clipboard
abstract fun replace(root: String, relativePath: String, content: String): Boolean

Overwrites an existing regular file's content. Refuses (false) when there is nothing there yet.

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