PlatformFile, including files and folders returned by FileKit dialogs, such as Android content:// documents.
Dependencies
Add kmp-zip and its kotlinx-io adapters alongside FileKit Core:build.gradle.kts
source() and sink() don’t exist, so build the archive in memory instead: see Zip on the web.
Create an archive
Thezip function below writes files and folders into an archive. Each folder keeps its name as the top-level entry, so extracting the archive recreates the folder:
nonWebMain
A few things to keep in mind:
- Save the archive outside the files and folders you are zipping. Otherwise,
zipcan read the archive while writing it, or overwrite a source file before reading it. - Symbolic links are followed. A link to a parent folder makes
ziploop through the same folders until it fails. - kmp-zip doesn’t support ZIP64. Each file and the archive must stay under 4 GB, with at most 65,535 entries.
Extract an archive
Theunzip function extracts every entry into a destination folder:
nonWebMain
Zip files picked by the user
Combined with FileKit Dialogs, you can let the user pick files and choose where to save the archive:nonWebMain
FileKit.openDirectoryPicker() and pass the folder to zip.
Zip on the web
Build the archive in memory, then save it withFileKit.download:
webMain