More progress on Readme.

This commit is contained in:
Timofey Solomko
2016-10-30 18:55:57 +03:00
parent 6959125411
commit 0264d5b6e2
+30 -9
View File
@@ -1,5 +1,5 @@
# SWCompression
*SWCompression* is framework for Swift which contains native (*written in Swift*)
A framework which contains native (*written in Swift*)
implementations of some compression algorithms.
### Why have you made compression framework?
@@ -16,9 +16,9 @@ that framework has a bit complicated API and somewhat questionable choice of sup
And here comes SWCompression: no Objective-C, pure Swift.
### Features
- Deflate decompression
- GZip unarchiving
- Zlib unarchiving
- Decompress data which were compressed with DEFLATE algorithm.
- Extract data from GZip archives.
- Unarchive zlib compressed data.
- _Swift only_
By the way, it seems like GZip and Deflate decompressor implementations are specification compliant.
@@ -30,7 +30,7 @@ Add to your Podfile `pod 'SWCompression'`.
Also, do not forget to have `use_frameworks!` line in the Podfile.
To complete installation, run `pod install`
To complete installation, run `pod install`.
##### Carthage
Add to your Cartfile `github "tsolomko/SWCompression"`.
@@ -40,11 +40,32 @@ Then run `carthage update`.
Finally, drag and drop `SWCompression.framework` from `Carthage/Build` folder into the "Embedded Binaries" section on your targets' "General" tab.
### Usage
If you'd like to decompress "deflated" data just use:
```swift
let data = try! Data(contentsOf: URL(fileURLWithPath: "path/to/file"))
let decompressedData = try? Deflate.decompress(compressedData: data)
```
**Note:** you should properly handle possible errors in loading data from file
and define yourself if you need any `Data.ReadingOptions`.
However, it is unlikely that you will encounter deflated data outside of any archive.
So, in case of GZip archive you should use:
```swift
let decompressedData = try? GzipArchive.unarchive(archiveData: data)
```
And, finally, for zlib the corresponding code is:
```swift
let decompressedData = try? ZlibArchive.unarchive(archiveData: data)
```
One final note: every unarchive/decompress function can throw an error and
you are responsible for handling them.
### Future plans
- BZip2 decompression support
- Deflate compression
- BZip2 compression
- BZip2 decompression support.
- Deflate compression.
- BZip2 compression.
- Something else...
### References
@@ -53,5 +74,5 @@ python implementation of GZip and BZip2.
There are also several specifications which were also very useful:
- [Deflate specification](https://www.ietf.org/rfc/rfc1951.txt)
- [GZip specification](https://ietf.org/rfc/rfc1952.txt)
- [GZip specification](https://www.ietf.org/rfc/rfc1952.txt)
- [Zlib specfication](https://www.ietf.org/rfc/rfc1950.txt)