Perfect Zip 简体中文
Perfect Zip utility
This Perfect module wraps the minizip C library and provides simple zip and unzip functionality.
For MacOS install minizip using homebrew:
brew install minizip
On Ubuntu, install minizip:
apt-get install libminizip-dev
Add this project as a dependency in your Package.swift file.
.Package(url: "https://github.com/PerfectlySoft/Perfect-Zip.git", majorVersion: 2, minor: 0)
The following will zip the specified directory:
import PerfectZip
let zippy = Zip()
let thisZipFile = "/path/to/ZipFile.zip"
let sourceDir = "/path/to/files/"
let ZipResult = zippy.zipFiles(
paths: [sourceDir],
zipFilePath: thisZipFile,
overwrite: true, password: ""
)
print("ZipResult Result: \(ZipResult.description)")
To unzip a file:
import PerfectZip
let zippy = Zip()
let sourceDir = "/path/to/files/"
let thisZipFile = "/path/to/ZipFile.zip"
let UnZipResult = zippy.unzipFile(
source: thisZipFile,
destination: sourceDir,
overwrite: true
)
print("Unzip Result: \(UnZipResult.description)")