createReader

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

If opening the archive fails, the underlying file descriptor is closed automatically before the exception is rethrown.

KioArch.createReader(File("archive.zip")).use { reader ->
reader.getEntries().forEach { println(it.name) }
}

Return

a new ArchiveReader for inspecting and extracting entries from file.

Parameters

file

the archive File to open.

Throws

if file does not exist or cannot be opened.

ArchiveException

if the file is not a valid supported archive or an I/O error occurs.

Creates an ArchiveReader directly from an Android ParcelFileDescriptor.

The returned ArchiveReader takes ownership of pfd and closes it when the reader is closed, or immediately if opening the archive fails.

Return

an ArchiveReader to inspect and extract entries from pfd.

Parameters

pfd

a seekable ParcelFileDescriptor pointing to the archive file.

Throws

if the archive is corrupted, unsupported, or an I/O error occurs.


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

The caller is responsible for ensuring that the application holds read permissions for uri.

KioArch.createReader(context, documentUri).use { reader ->
for (entry in reader.getEntries()) {
println("${entry.name}: ${entry.size} bytes")
}
}

Return

an ArchiveReader to inspect and extract entries from uri.

Parameters

context

the Android Context used to access the ContentResolver.

uri

the content:// or file:// Uri of the archive file.

Throws

if uri cannot be resolved or opened.

if the archive is corrupted, unsupported, or an I/O error occurs.