Swiftpack.co - apparata/Zipcode as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by apparata.
apparata/Zipcode 0.2.0
Zipcode is a simple Swift framework for reading and writing zip files.
⭐️ 1
🕓 2 years ago
iOS macOS tvOS
.package(url: "https://github.com/apparata/Zipcode.git", from: "0.2.0")

Zipcode

Zipcode is a simple Swift framework for reading and writing zip files.

License

Zipcode is public domain. See UNLICENSE file for details.

Zipcode is based around zip which in turn is based on miniz. Both zip and miniz are public domain under the UNLICENSE license.

Examples

Printing the number of entries and the name of the entries in a zip file:

let archive = ZipArchive(path: "/tmp/Zipcode.zip")
try archive.read { reader in
    print("Number of entries: ", try reader.entryCount())
    let entries = try reader.entries()
    for entry in entries {
        print(entry.name)
    }
}

Unzipping an entry into memory:

let archive = ZipArchive(path: "/tmp/Zipcode.zip")
try archive.read { reader in
    let data = try reader.readEntryNamed("Zipcode/Package.swift")
    let string = String(data: data, encoding: .utf8) ?? "<Data is not a string>"
    print(string)
}

Writing text files to a zip file:

let archive = ZipArchive(path: "/tmp/Zipcode.zip")
try archive.write(type: .overwrite) { writer in
    try writer.writeEntryNamed("textfile1.txt", "Text Content 1".data(using: .utf8))
    try writer.writeEntryNamed("otherfiles/textfile2.txt", "Text Content 2".data(using: .utf8)) 
}

GitHub

link
Stars: 1
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

First release
4 years ago

Basic reading and writing of zip files have been implemented.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics