FirmwareFileHandler

Abstraction over platform file and network I/O required by the firmware update pipeline. Implementations live in androidMain and jvmMain.

Inheritors

Functions

Link copied to clipboard
abstract suspend fun checkUrlExists(url: String): Boolean

Return true if url is reachable (HTTP HEAD check).

Link copied to clipboard

Remove all temporary firmware files created during previous update sessions.

Link copied to clipboard
abstract suspend fun copyToUri(source: FirmwareArtifact, destinationUri: CommonUri): Long

Copy source to the platform URI destinationUri, returning the number of bytes written.

Link copied to clipboard
abstract suspend fun createDocumentInTree(treeUri: CommonUri, fileName: String, mimeType: String): CommonUri?

Creates fileName inside treeUri and returns a URI to write to, or null on failure.

Link copied to clipboard
abstract suspend fun deleteFile(file: FirmwareArtifact)

Delete a single firmware file from local storage.

Link copied to clipboard
abstract suspend fun downloadFile(url: String, fileName: String, onProgress: (Float) -> Unit): FirmwareArtifact?

Download a file from url, saving it as fileName in a temporary directory.

Link copied to clipboard
abstract suspend fun extractFirmware(uri: CommonUri, hardware: DeviceHardware, fileExtension: String, preferredFilename: String? = null): FirmwareArtifact?

Extract a matching firmware binary from a platform URI (e.g. content:// or file://) zip archive.

Link copied to clipboard
abstract suspend fun extractFirmwareFromZip(zipFile: FirmwareArtifact, hardware: DeviceHardware, fileExtension: String, preferredFilename: String? = null): FirmwareArtifact?

Extract a matching firmware binary from a previously-downloaded zip FirmwareArtifact.

Link copied to clipboard
abstract suspend fun extractZipEntries(artifact: FirmwareArtifact): Map<String, ByteArray>

Extract all entries from a zip artifact into a Map<entryName, bytes>. Used by the DFU handler to parse Nordic DFU packages.

Link copied to clipboard
abstract suspend fun fetchText(url: String): String?

Fetch the UTF-8 text body of url, returning null on any HTTP or network error.

Link copied to clipboard
abstract suspend fun getDisplayName(uri: CommonUri): String?

Resolve a user-visible display filename for uri, or null when the provider does not expose one.

Link copied to clipboard
abstract suspend fun getFileSize(file: FirmwareArtifact): Long

Return the size in bytes of the given firmware file.

Link copied to clipboard
abstract suspend fun importFromUri(uri: CommonUri): FirmwareArtifact?

Copy a platform URI into a temporary FirmwareArtifact so it can be read with readBytes. Returns null when the URI cannot be resolved.

Link copied to clipboard
abstract suspend fun isDestinationReadable(destinationUri: CommonUri): Boolean

True when destinationUri can still be opened for reading.

Link copied to clipboard
abstract suspend fun isRemovableDestination(destinationUri: CommonUri): Boolean

Best-effort check that destinationUri names a location on removable storage — i.e. plausibly a mounted UF2 bootloader drive rather than internal storage.

Link copied to clipboard
abstract suspend fun readBytes(artifact: FirmwareArtifact): ByteArray

Read the raw bytes of a FirmwareArtifact.

Link copied to clipboard
abstract suspend fun readSiblingText(treeUri: CommonUri, fileName: String): String?

Reads a file sitting alongside the documents in treeUri, or null when it is absent or unreadable.