https://github.com/meniny/zipper
đłA library to create, read and modify ZIP archive files, written in Swift.
https://github.com/meniny/zipper
archive compression zip
Last synced: over 1 year ago
JSON representation
đłA library to create, read and modify ZIP archive files, written in Swift.
- Host: GitHub
- URL: https://github.com/meniny/zipper
- Owner: Meniny
- License: mit
- Created: 2017-07-06T18:40:53.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-03-27T18:43:55.000Z (about 3 years ago)
- Last Synced: 2025-03-18T03:51:26.307Z (over 1 year ago)
- Topics: archive, compression, zip
- Language: Swift
- Homepage:
- Size: 197 KB
- Stars: 40
- Watchers: 3
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE.md
Awesome Lists containing this project
README
:name: Zipper
:author: Elias Abel
:author_esc: Elias%20Abel
:mail: admin@meniny.cn
:desc: a Effortless ZIP Handling in Swift
:icon: {name}.png
:version: 1.2.0
:na: N/A
:ios: 9.0
:macos: 10.11
:watchos: 2.0
:tvos: 9.0
:linux: with `zlib`
:xcode: 10.2
:swift: 5
:license: MIT
:sep: %20%7C%20
:platform: iOS{sep}macOS{sep}watchOS{sep}tvOS{sep}Linux
= Meet `{name}`
{author} <{mail}>
v{version}, 2019-04-16
[subs="attributes"]
++++
++++
:toc:
== đľ Introduction
**{name}** is {desc}.
== đ Requirements
[%header]
|===
2+^m|Type 1+^m|Requirement
1.5+^.^|Platform ^|iOS ^|{ios}+
^|macOS ^|{macos}
^|tvOS ^|{tvos}
^|watchOS ^|{watchos}
^|Linux ^|{linux}
^|IDE ^|Xcode ^| {xcode}+
^|Language ^|Swift ^| {swift}+
|===
== đ˛ Installation
=== CocoaPods
`{name}` is available on link:https://cocoapods.org[CocoaPods].
[source, ruby, subs="verbatim,attributes"]
----
use_frameworks!
pod '{name}'
----
=== Manually
Copy all files in the `{name}` directory into your project.
== đ Dependency
{na}
== â¤ď¸ Contribution
You are welcome to fork and submit pull requests.
== đ License
`{name}` is open-sourced software, licensed under the link:./LICENSE.md[`{license}`] license.
== đŤ Usage
[source, swift, subs="verbatim,attributes"]
----
import {name}
let fileManager = FileManager()
let currentDirectoryURL = URL(fileURLWithPath: fileManager.currentDirectoryPath)
----
=== Zipping
[source, swift, subs="verbatim,attributes"]
----
var archiveURL = currentDirectoryURL.appendPathComponent("archive.zip")
var resourcesURL = currentDirectoryURL.appendPathComponent("directory")
// zip:
do {
try fileManager.zip(item: resourcesURL, to: archive)
} catch _ {}
// or:
guard let archive = Zipper(url: archiveURL, accessMode: .create) else { return }
do {
try archive.zip(item: resourcesURL)
} catch {
}
----
=== Unzipping
[source, swift, subs="verbatim,attributes"]
----
var archiveURL = currentDirectoryURL.appendPathComponent("archive.zip")
var destinationURL = currentDirectoryURL.appendPathComponent("directory")
// unzip:
do {
try fileManager.createDirectory(at: destinationURL, withIntermediateDirectories: true, attributes: nil)
try fileManager.unzip(item: archiveURL, to: destinationURL)
} catch {
}
// or:
guard let archive = Zipper(url: archiveURL, accessMode: .read) else { return }
do {
try archive.unzip(to: destinationURL)
} catch {
}
----
=== Accessing individual Entries
[source, swift, subs="verbatim,attributes"]
----
var archiveURL = currentDirectoryURL.appendPathComponent("archive.zip")
guard let archive = Zipper(url: archiveURL, accessMode: .read) else { return }
guard let entry = archive["file.txt"] else { return }
var destinationURL = currentDirectoryURL.appendPathComponent("output.txt")
do {
try archive.extract(entry, to: destinationURL)
} catch {
}
----
=== Adding/Removing Entries
[source, swift, subs="verbatim,attributes"]
----
var archiveURL = currentDirectoryURL.appendPathComponent("archive.zip")
var fileURL = currentDirectoryURL.appendPathComponent("file.ext")
----
==== Adding:
[source, swift, subs="verbatim,attributes"]
----
guard let archive = Zipper(url: archiveURL, accessMode: .update) else { return }
do {
try archive.addEntry(with: fileURL.lastPathComponent, relativeTo: fileURL.deletingLastPathComponent())
} catch {
}
----
==== Removing:
[source, swift, subs="verbatim,attributes"]
----
guard let entry = archive["file.txt"] else { return }
do {
try archive.remove(entry)
} catch {
}
----