forked from marmelroy/Zip
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fix testing and CI - Small refactor with no breaking changes - Bump minimum Swift version to 5.8 - Remove all CocoaPods and useless files
- Loading branch information
1 parent
1d63e04
commit 32b3e3e
Showing
62 changed files
with
407 additions
and
3,212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
version: 1 | ||
builder: | ||
configs: | ||
- documentation_targets: [Zip] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,78 @@ | ||
 | ||
<div align="center"> | ||
<img src="https://cloud.githubusercontent.com/assets/889949/12374908/252373d0-bcac-11e5-8ece-6933aeae8222.png" max-height="200" alt="avatar" /> | ||
<a href="https://swiftpackageindex.com/vapor-community/Zip/documentation"> | ||
<img src="https://design.vapor.codes/images/readthedocs.svg" alt="Documentation"> | ||
</a> | ||
<a href="https://discord.gg/vapor"><img src="https://design.vapor.codes/images/discordchat.svg" alt="Team Chat"></a> | ||
<a href="LICENSE"><img src="https://design.vapor.codes/images/mitlicense.svg" alt="MIT License"></a> | ||
<a href="https://github.com/vapor-community/Zip/actions/workflows/test.yml"> | ||
<img src="https://img.shields.io/github/actions/workflow/status/vapor-community/Zip/test.yml?event=push&style=plastic&logo=github&label=tests&logoColor=%23ccc" alt="Continuous Integration"> | ||
</a> | ||
<a href="https://codecov.io/github/vapor-community/Zip"> | ||
<img src="https://img.shields.io/codecov/c/github/vapor-community/Zip?style=plastic&logo=codecov&label=codecov"> | ||
</a> | ||
<a href="https://swift.org"> | ||
<img src="https://design.vapor.codes/images/swift58up.svg" alt="Swift 5.8+"> | ||
</a> | ||
</div> | ||
<br> | ||
|
||
A framework for zipping and unzipping files in Swift. | ||
|
||
Simple and quick to use. | ||
Built on top of [minizip](https://github.com/nmoinvaz/minizip). | ||
|
||
Use the SPM string to easily include the dependendency in your `Package.swift` file. | ||
|
||
[](https://travis-ci.org/marmelroy/Zip) [](http://cocoapods.org/?q=Zip) [](https://github.com/Carthage/Carthage) [](https://swift.org/package-manager) | ||
|
||
|
||
# Zip | ||
A Swift framework for zipping and unzipping files. Simple and quick to use. Built on top of [minizip](https://github.com/nmoinvaz/minizip). | ||
```swift | ||
.package(url: "https://github.com/vapor-community/Zip.git", from: "2.1.3") | ||
``` | ||
|
||
## Usage | ||
|
||
Import Zip at the top of the Swift file. | ||
### Quick functions | ||
|
||
The easiest way to use Zip is through quick functions. Both take local file paths as `URL`s, throw if an error is encountered and return an `URL` to the destination if successful. | ||
|
||
```swift | ||
import Zip | ||
``` | ||
|
||
## Quick functions | ||
|
||
The easiest way to use Zip is through quick functions. Both take local file paths as NSURLs, throw if an error is encountered and return an NSURL to the destination if successful. | ||
```swift | ||
do { | ||
let filePath = Bundle.main.url(forResource: "file", withExtension: "zip")! | ||
let unzipDirectory = try Zip.quickUnzipFile(filePath) // Unzip | ||
let zipFilePath = try Zip.quickZipFiles([filePath], fileName: "archive") // Zip | ||
} | ||
catch { | ||
let filePath = Bundle.main.url(forResource: "file", withExtension: "zip")! | ||
let unzipDirectory = try Zip.quickUnzipFile(filePath) | ||
let zipFilePath = try Zip.quickZipFiles([filePath], fileName: "archive") | ||
} catch { | ||
print("Something went wrong") | ||
} | ||
``` | ||
|
||
## Advanced Zip | ||
### Advanced Zip | ||
|
||
For more advanced usage, Zip has functions that let you set custom destination paths, work with password protected zips and use a progress handling closure. These functions throw if there is an error but don't return. | ||
```swift | ||
do { | ||
let filePath = Bundle.main.url(forResource: "file", withExtension: "zip")! | ||
let documentsDirectory = FileManager.default.urls(for:.documentDirectory, in: .userDomainMask)[0] | ||
try Zip.unzipFile(filePath, destination: documentsDirectory, overwrite: true, password: "password", progress: { (progress) -> () in | ||
print(progress) | ||
}) // Unzip | ||
For more advanced usage, Zip has functions that let you set custom destination paths, work with password protected zips and use a progress handling closure. These functions throw if there is an error but don't return. | ||
|
||
let zipFilePath = documentsFolder.appendingPathComponent("archive.zip") | ||
try Zip.zipFiles([filePath], zipFilePath: zipFilePath, password: "password", progress: { (progress) -> () in | ||
print(progress) | ||
}) //Zip | ||
```swift | ||
import Zip | ||
|
||
} | ||
catch { | ||
do { | ||
let filePath = Bundle.main.url(forResource: "file", withExtension: "zip")! | ||
let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] | ||
try Zip.unzipFile(filePath, destination: documentsDirectory, overwrite: true,password: "password", progress: { (progress) -> () in | ||
print(progress) | ||
}) | ||
|
||
let zipFilePath = documentsFolder.appendingPathComponent("archive.zip") | ||
try Zip.zipFiles([filePath], zipFilePath: zipFilePath, password: "password", progress: { (progress) -> () in | ||
print(progress) | ||
}) | ||
} catch { | ||
print("Something went wrong") | ||
} | ||
``` | ||
|
||
## Custom File Extensions | ||
### Custom File Extensions | ||
|
||
Zip supports '.zip' and '.cbz' files out of the box. To support additional zip-derivative file extensions: | ||
```swift | ||
Zip.addCustomFileExtension("file-extension-here") | ||
``` | ||
Zip supports `.zip` and `.cbz` files out of the box. To support additional zip-derivative file extensions: | ||
|
||
### [Preferred] Setting up with [Swift Package Manager](https://swift.org/package-manager) | ||
To use Zip with Swift Package Manager, add it to your package's dependencies: | ||
```swift | ||
.package(url: "https://github.com/marmelroy/Zip.git", .upToNextMinor(from: "2.1")) | ||
``` | ||
|
||
### Setting up with [CocoaPods](http://cocoapods.org/?q=Zip) | ||
```ruby | ||
source 'https://github.com/CocoaPods/Specs.git' | ||
pod 'Zip', '~> 2.1' | ||
``` | ||
|
||
### Setting up with [Carthage](https://github.com/Carthage/Carthage) | ||
To integrate Zip into your Xcode project using Carthage, specify it in your `Cartfile`: | ||
|
||
```ogdl | ||
github "marmelroy/Zip" ~> 2.1 | ||
Zip.addCustomFileExtension("file-extension-here") | ||
``` | ||
|
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.