Kio Arch
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
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 vialoadKioArchModule()) before invoking anycreateReaderoverload.
iOS implementation of KioArch leveraging pure C archive decompression engine.
JS implementation of KioArch utilizing WebAssembly compiled from pure C archive engines.
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.
Functions
Creates an ArchiveReader reading from the given source on Android.
Creates an ArchiveReader reading from an in-memory byteArray on Android.
Creates an ArchiveReader reading from a Kotlin Multiplatform path on Android via PathSeekableSource.
Creates an ArchiveReader reading from the given random-access source.
Creates an ArchiveReader reading from an in-memory byteArray.
Creates an ArchiveReader reading from the file at the specified path.
Creates an ArchiveReader from a custom SeekableSource for iOS.
Creates an ArchiveReader from an in-memory ByteArray for iOS.
Creates an ArchiveReader from a Kotlin Multiplatform Path for iOS.
Creates an ArchiveReader from an in-memory Foundation NSData buffer for iOS.
Creates an ArchiveReader from a Foundation NSFileHandle for iOS.
Creates an ArchiveReader from a Foundation file NSURL for iOS.
Creates an ArchiveReader from a custom SeekableSource for JS.
Creates an ArchiveReader from an in-memory ByteArray for JS.
Creates an ArchiveReader from a Kotlin Multiplatform Path for JS.
Creates an ArchiveReader reading from the given source on JVM.
Creates an ArchiveReader reading from an in-memory byteArray on JVM.
Creates an ArchiveReader reading from a Kotlin Multiplatform path on JVM via PathSeekableSource.
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.
Returns the canonical lowercase file extensions for all archive formats supported by KioArch.
Explicitly loads the native libkioarch.so shared library if it has not been loaded yet.