KioArch

actual object KioArch(source)

Android implementation of KioArch backed by JNI bindings to libkioarch.so.

By default, KioArchInitializer preloads libkioarch.so via Jetpack App Startup when the application process starts. If automatic initialization is disabled in AndroidManifest.xml, loadLibrary can be called explicitly during background initialization, or createReader will load the native library lazily on first use.

See also

expect object KioArch(source)

Entry point for creating ArchiveReader instances across all supported Kotlin Multiplatform targets.

KioArch inspects the leading magic bytes of the input stream to determine the archive format automatically, rather than relying on file extensions. Supported formats are defined in ArchiveFormat.

Usage Example

import com.sorrowblue.kioarch.KioArch
import com.sorrowblue.kioarch.extractToByteArray
import kotlinx.io.files.Path

KioArch.createReader(Path("example.7z")).use { reader ->
for (entry in reader.getEntries()) {
if (!entry.isDirectory) {
val content = entry.extractToByteArray(reader)
println("Extracted ${entry.name} (${content.size} bytes)")
}
}
}

Platform Initialization Notes

  • JVM / iOS: Native decompression libraries are linked or extracted automatically on first use.

  • Android: Preloaded automatically at startup via KioArchInitializer, or loaded on demand if App Startup initialization is disabled.

  • JS / WasmJs: Call KioArch.initialize(module) with a resolved Emscripten module instance (obtained via loadKioArchModule()) before invoking any createReader overload.

actual object KioArch(source)

iOS implementation of KioArch leveraging pure C archive decompression engine.

actual object KioArch(source)

JS implementation of KioArch utilizing WebAssembly compiled from pure C archive engines.

actual object KioArch(source)

JVM implementation of KioArch backed by JNI bindings to the native C decompression engine.

On first invocation of createReader, the embedded platform native library (.dll on Windows, .dylib on macOS, or .so on Linux) is automatically extracted from classpath resources and loaded into the JVM process if not already present on java.library.path.

actual object KioArch(source)

WasmJs implementation of KioArch utilizing WebAssembly compiled from pure C archive engines.

Functions

Link copied to clipboard

Creates an ArchiveReader reading from the given source on Android.

actual fun createReader(byteArray: ByteArray): ArchiveReader

Creates an ArchiveReader reading from an in-memory byteArray on Android.

actual fun createReader(path: Path): ArchiveReader

Creates an ArchiveReader reading from a Kotlin Multiplatform path on Android via PathSeekableSource.

Creates an ArchiveReader reading from the given random-access source.

expect fun createReader(byteArray: ByteArray): ArchiveReader

Creates an ArchiveReader reading from an in-memory byteArray.

expect fun createReader(path: Path): ArchiveReader

Creates an ArchiveReader reading from the file at the specified path.

actual fun createReader(source: SeekableSource): ArchiveReader

Creates an ArchiveReader from a custom SeekableSource for iOS.

actual fun createReader(byteArray: ByteArray): ArchiveReader

Creates an ArchiveReader from an in-memory ByteArray for iOS.

actual fun createReader(path: Path): ArchiveReader

Creates an ArchiveReader from a Kotlin Multiplatform Path for iOS.

fun createReader(nsData: NSData): ArchiveReader

Creates an ArchiveReader from an in-memory Foundation NSData buffer for iOS.

fun createReader(fileHandle: NSFileHandle): ArchiveReader

Creates an ArchiveReader from a Foundation NSFileHandle for iOS.

fun createReader(nsUrl: NSURL): ArchiveReader

Creates an ArchiveReader from a Foundation file NSURL for iOS.

actual fun createReader(source: SeekableSource): ArchiveReader

Creates an ArchiveReader from a custom SeekableSource for JS.

actual fun createReader(byteArray: ByteArray): ArchiveReader

Creates an ArchiveReader from an in-memory ByteArray for JS.

actual fun createReader(path: Path): ArchiveReader

Creates an ArchiveReader from a Kotlin Multiplatform Path for JS.

Creates an ArchiveReader reading from the given source on JVM.

actual fun createReader(byteArray: ByteArray): ArchiveReader

Creates an ArchiveReader reading from an in-memory byteArray on JVM.

actual fun createReader(path: Path): ArchiveReader

Creates an ArchiveReader reading from a Kotlin Multiplatform path on JVM via PathSeekableSource.

actual fun createReader(source: SeekableSource): ArchiveReader

Creates an ArchiveReader from a custom SeekableSource for WasmJs.

actual fun createReader(byteArray: ByteArray): ArchiveReader

Creates an ArchiveReader from an in-memory ByteArray for WasmJs.

actual fun createReader(path: Path): ArchiveReader

Creates an ArchiveReader from a Kotlin Multiplatform Path for WasmJs.

Link copied to clipboard

Creates an ArchiveReader reading directly from a java.io.File via FileSeekableSource.

Creates an ArchiveReader directly from an Android ParcelFileDescriptor.

Creates an ArchiveReader directly from an Android content Uri resolved via context.contentResolver.

Link copied to clipboard

Returns the canonical lowercase file extensions for all archive formats supported by KioArch.

Link copied to clipboard
actual fun KioArch.initialize(module: Any)

Registers the instantiated Emscripten WebAssembly module with KioArch on the Kotlin/JS target.

actual fun KioArch.initialize(module: Any)

Registers the instantiated Emscripten WebAssembly module with KioArch on the Kotlin/WasmJs target and initializes the internal JS callback maps.

expect fun KioArch.initialize(module: Any)

Registers the instantiated Emscripten WebAssembly module with KioArch.

Link copied to clipboard

Explicitly loads the native libkioarch.so shared library if it has not been loaded yet.