Swiftpack.co -  apparata/Zipcode as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
apparata/Zipcode
Zipcode is a simple Swift framework for reading and writing zip files.
.package(url: "https://github.com/apparata/Zipcode.git", from: "0.1.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: 0
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

First release
1 year ago

Basic reading and writing of zip files have been implemented.

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