Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Tests #2

Merged
merged 10 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .spi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: 1
builder:
configs:
- documentation_targets: [Zip]
1 change: 0 additions & 1 deletion .swift-version

This file was deleted.

19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

41 changes: 0 additions & 41 deletions CHANGELOG.md

This file was deleted.

8 changes: 0 additions & 8 deletions LinuxMain.swift

This file was deleted.

23 changes: 15 additions & 8 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
// swift-tools-version:5.8
import PackageDescription

let package = Package(
Expand All @@ -10,20 +9,28 @@ let package = Package(
targets: [
.target(
name: "Minizip",
dependencies: [],
path: "Zip/minizip",
exclude: ["module"],
linkerSettings: [
.linkedLibrary("z")
]),
]
),
.target(
name: "Zip",
dependencies: ["Minizip"],
dependencies: [
.target(name: "Minizip"),
],
path: "Zip",
exclude: ["minizip", "zlib"]),
exclude: ["minizip", "zlib"]
),
.testTarget(
name: "ZipTests",
dependencies: ["Zip"],
path: "ZipTests"),
dependencies: [
.target(name: "Zip"),
],
resources: [
.copy("Resources"),
]
),
]
)
30 changes: 0 additions & 30 deletions [email protected]

This file was deleted.

29 changes: 0 additions & 29 deletions [email protected]

This file was deleted.

108 changes: 54 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,78 +1,78 @@
![Zip - Zip and unzip files in Swift](https://cloud.githubusercontent.com/assets/889949/12374908/252373d0-bcac-11e5-8ece-6933aeae8222.png)
<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.

[![Build Status](https://travis-ci.org/marmelroy/Zip.svg?branch=master)](https://travis-ci.org/marmelroy/Zip) [![Version](http://img.shields.io/cocoapods/v/Zip.svg)](http://cocoapods.org/?q=Zip) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![SPM supported](https://img.shields.io/badge/SPM-supported-brightgreen.svg?style=flat)](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.
Loading