https://github.com/rushiimachine/zip-android
Native zip library + java interface for android
https://github.com/rushiimachine/zip-android
android java kotlin rust zip
Last synced: 5 months ago
JSON representation
Native zip library + java interface for android
- Host: GitHub
- URL: https://github.com/rushiimachine/zip-android
- Owner: rushiiMachine
- License: apache-2.0
- Created: 2022-03-17T05:02:05.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-01-17T21:57:21.000Z (over 1 year ago)
- Last Synced: 2024-10-16T17:48:14.298Z (7 months ago)
- Topics: android, java, kotlin, rust, zip
- Language: Rust
- Homepage:
- Size: 354 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# zip-android 
Android JNI bindings for [zip-rs](https://github.com/zip-rs/zip), a native rust zip library.
### Installation
```kotlin
repositories {
mavenCentral()
}dependencies {
implementation("io.github.diamondminer88:zip-android:2.1.1@aar")
}
```### Example Usage (Kotlin)
```kotlin
ZipReader(zipFile).use { zip ->
"Entry count: ${zip.entryCount}"
"Entries: ${zip.entryNames.joinToString()}"// Loop over entries
zip.entries().forEach { /* guh */ }
zip.forEach {
"Entry: ${it.name} size: ${it.size} modified: ${it.lastModified}"
if (it.isFile) {
"Content: ${it.read().decodeToString()}"
}
}
}// Close reader/writer by using .use {} (kotlin) or .close()/try block for java
ZipWriter(zipFile).use { zip ->
zip.setComment("a comment".toByteArray())
zip.writeEntry("compressed.txt", "hot garbage")
zip.writeEntry("data/compressed_bytes.txt", bytes)
zip.writeDir("com/github/diamondminer88/zip")
zip.deleteEntries("abc.txt", "guh.txt")
zip.deleteEntry("husk.txt")// Delete entry from central dir and keep the existing alignment (useful for writing zip aligned .so's)
zip.deleteEntry("lib.so", /* fillVoid = */ true)
// Write page-aligned (4096 byte) uncompressed entry (useful for writing zip aligned .so's)
zip.writeEntry("lib.so", bytes, ZipCompression.NONE, 4096)
}
```### Building Prerequisites
1. `rustup install nightly && rustup default nightly`
2. `rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android i686-linux-android`
3. `cargo install --force cargo-ndk`