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 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 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 readBytes(artifact: FirmwareArtifact): ByteArray

Read the raw bytes of a FirmwareArtifact.