mirror of
https://github.com/tsolomko/SWCompression.git
synced 2026-11-18 21:40:30 +00:00
Merge branch 'release-4.3.0'
This commit is contained in:
66 files changed
+977
-532
No files matched your search
+4
-2
@@ -3,11 +3,11 @@ sourcekitten_sourcefile: docs.json
|
||||
clean: true
|
||||
author: Timofey Solomko
|
||||
module: SWCompression
|
||||
module_version: 4.2.2
|
||||
module_version: 4.3.0
|
||||
copyright: '© 2018 Timofey Solomko'
|
||||
readme: README.md
|
||||
github_url: https://github.com/tsolomko/SWCompression
|
||||
github_file_prefix: https://github.com/tsolomko/SWCompression/tree/4.2.2
|
||||
github_file_prefix: https://github.com/tsolomko/SWCompression/tree/4.3.0
|
||||
theme: fullwidth
|
||||
|
||||
custom_categories:
|
||||
@@ -35,6 +35,8 @@ custom_categories:
|
||||
- ZipContainer
|
||||
- ZipEntry
|
||||
- ZipEntryInfo
|
||||
- ZipExtraField
|
||||
- ZipExtraFieldLocation
|
||||
- name: Errors
|
||||
children:
|
||||
- BZip2Error
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
4.0
|
||||
4.1
|
||||
@@ -1,6 +1,7 @@
|
||||
excluded:
|
||||
- .build/
|
||||
- Package.swift
|
||||
- Carthage/
|
||||
disabled_rules:
|
||||
- cyclomatic_complexity
|
||||
- file_length
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ jobs:
|
||||
- stage: test
|
||||
language: objective-c
|
||||
os: osx
|
||||
osx_image: xcode9.2
|
||||
osx_image: xcode9.3
|
||||
before_install:
|
||||
- brew update
|
||||
install:
|
||||
@@ -26,7 +26,7 @@ jobs:
|
||||
if: tag IS present
|
||||
language: objective-c
|
||||
os: osx
|
||||
osx_image: xcode9.2
|
||||
osx_image: xcode9.3
|
||||
env:
|
||||
secure: iavIkrus2Xd3b086nz2srMGl52yqzLuCdhyEAhMODVqkzqMQ17s10y1TNb+vkepd0HgxI9j57d5X7tfChjWuWDwE2hZKjr/Kx2DfiUr1AKQD6ymuGrq/0Vv6yL9dfPU8goFArcrsBcyVKczLtTuLCKL498ZqokkQc/3kGvzW74lv+z410MfHS9/tvToO/yXJckL6qJ2XBAiElfOO0rEkllTeCo6N3bjcHZ2o7PE0K+CHYxwNKj0TmPmuNWZ3U4fzoWzkk01re1C1l5cpSb20g+2aGyi0yYX+PomX7fIIqNq9vmmyoeNdr35yqoQv/0zFeFnps83NKmZLAjSUhiUdhlbuBLBE+w8544LOaZnMDlFmpDjgyaVnRrOh0NrBB1FwU48aGfX5ljRQmk/07FTEUjvwvGGoOpz8lrLZi148FMHEospL3Sf7d8K+Q9WdtLTGk7HCnbOVcxS6oB/SWF/Cj6n5wu+EI1floBaZEsNPR40Gd4eM/Ik/E3lDrZThGDCWQsao981wm7IfEDBR1nuMME8gpZINFANNS1+5miFaGdTnDTp4Yd5MGEFZm+K8x+TG1891NwNH1ZmKXlypJXiUzvSjbh2ViNJGekdQj9q2gj2ZFlCfHJ05adwJ4w9qRuF00HpAOD6At6EnsjDXFJeTZS5dj8fi2YsU9or8KfTFoNY=
|
||||
before_install:
|
||||
|
||||
@@ -1,5 +1,25 @@
|
||||
# Changelog
|
||||
|
||||
## 4.3.0
|
||||
|
||||
- Updated to support Swift 4.1.
|
||||
- Minuimum required version of BitByteData is now 1.2.0.
|
||||
- Added APIs which allow to use custom ZIP Extra Fields.
|
||||
- Added `ZipExtraField` protocol.
|
||||
- Added `ZipExtraFieldLocation` enum.
|
||||
- Added `ZipContainer.customExtraFields` property.
|
||||
- Added `ZipEntryInfo.customExtraFields` property.
|
||||
- Added APIs which allow to get information about TAR's format:
|
||||
- Added `TarContainer.Format` enum which represents various formats of TAR containers.
|
||||
- Added `TarContainer.formatOf(container:)` function which returns format of the container.
|
||||
- Added `-f`, `--format` option to swcomp's `tar` command which prints format of TAR container.
|
||||
- Added `TarEntryInfo.compressionMethod` property which is always equal to `.copy`.
|
||||
- Added documenation for `Container.Entry` and `ContainerEntry.Info` associated types.
|
||||
- Reverted "disable symbol stripping" change from 4.2.0 update, since underlying problem was fixed in Carthage.
|
||||
- Benchmarks changes:
|
||||
- Iterations number increased from 6 to 10.
|
||||
- There is now a zeroth iteration which is excluded from averages.
|
||||
|
||||
## 4.2.2
|
||||
|
||||
- Fixed skipping entries in `SevenZipContainer.open(container:)` in some rare cases.
|
||||
|
||||
@@ -1 +1 @@
|
||||
github "tsolomko/BitByteData" ~> 1.1
|
||||
github "tsolomko/BitByteData" ~> 1.2
|
||||
+2
-2
@@ -11,9 +11,9 @@ let package = Package(
|
||||
dependencies: [
|
||||
// SWCOMP: Uncomment the line below to build swcomp example program.
|
||||
// .package(url: "https://github.com/jakeheis/SwiftCLI",
|
||||
// from: "4.0.0"),
|
||||
// from: "5.0.0"),
|
||||
.package(url: "https://github.com/tsolomko/BitByteData",
|
||||
from: "1.1.0"),
|
||||
from: "1.2.0"),
|
||||
],
|
||||
targets: [
|
||||
// SWCOMP: Uncomment the lines below to build swcomp example program.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# SWCompression
|
||||
|
||||
[](https://developer.apple.com/swift/)
|
||||
[](https://developer.apple.com/swift/)
|
||||
[](https://raw.githubusercontent.com/tsolomko/SWCompression/master/LICENSE)
|
||||
[](https://travis-ci.org/tsolomko/SWCompression)
|
||||
|
||||
@@ -51,7 +51,7 @@ let package = Package(
|
||||
name: "PackageName",
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/tsolomko/SWCompression.git",
|
||||
from: "4.2.0")
|
||||
from: "4.3.0")
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
@@ -66,7 +66,7 @@ More details you can find in [Swift Package Manager's Documentation](https://git
|
||||
|
||||
### CocoaPods
|
||||
|
||||
Add `pod 'SWCompression', '~> 4.2'` and `use_frameworks!` to your Podfile.
|
||||
Add `pod 'SWCompression', '~> 4.3'` and `use_frameworks!` to your Podfile.
|
||||
|
||||
To complete installation, run `pod install`.
|
||||
|
||||
@@ -112,7 +112,7 @@ __Note:__ If you use Swift Package Manager or Carthage you always have everythin
|
||||
|
||||
### Carthage
|
||||
|
||||
Add to your Cartfile `github "tsolomko/SWCompression" ~> 4.2`.
|
||||
Add to your Cartfile `github "tsolomko/SWCompression" ~> 4.3`.
|
||||
|
||||
Then run `carthage update`.
|
||||
|
||||
|
||||
+34
-34
@@ -1,7 +1,7 @@
|
||||
Pod::Spec.new do |s|
|
||||
|
||||
s.name = "SWCompression"
|
||||
s.version = "4.2.2"
|
||||
s.version = "4.3.0"
|
||||
s.summary = "A framework with functions for working with compression, archives and containers."
|
||||
|
||||
s.description = "A framework with (de)compression algorithms and functions for processing various archives and containers."
|
||||
@@ -20,59 +20,59 @@ Pod::Spec.new do |s|
|
||||
s.tvos.deployment_target = "9.0"
|
||||
s.watchos.deployment_target = "2.0"
|
||||
|
||||
s.swift_version = '4.0'
|
||||
s.swift_version = "4.1"
|
||||
|
||||
s.dependency 'BitByteData', '~> 1.1'
|
||||
s.dependency "BitByteData", "~> 1.2.0"
|
||||
|
||||
s.subspec 'Deflate' do |sp|
|
||||
sp.source_files = 'Sources/{Deflate/*,Common/*}.swift'
|
||||
sp.pod_target_xcconfig = { 'OTHER_SWIFT_FLAGS' => '-DSWCOMPRESSION_POD_DEFLATE' }
|
||||
s.subspec "Deflate" do |sp|
|
||||
sp.source_files = "Sources/{Deflate/*,Common/*}.swift"
|
||||
sp.pod_target_xcconfig = { "OTHER_SWIFT_FLAGS" => "-DSWCOMPRESSION_POD_DEFLATE" }
|
||||
end
|
||||
|
||||
s.subspec 'GZip' do |sp|
|
||||
sp.dependency 'SWCompression/Deflate'
|
||||
sp.source_files = 'Sources/{GZip/*,Common/*}.swift'
|
||||
s.subspec "GZip" do |sp|
|
||||
sp.dependency "SWCompression/Deflate"
|
||||
sp.source_files = "Sources/{GZip/*,Common/*}.swift"
|
||||
end
|
||||
|
||||
s.subspec 'Zlib' do |sp|
|
||||
sp.dependency 'SWCompression/Deflate'
|
||||
sp.source_files = 'Sources/{Zlib/*,Common/*}.swift'
|
||||
s.subspec "Zlib" do |sp|
|
||||
sp.dependency "SWCompression/Deflate"
|
||||
sp.source_files = "Sources/{Zlib/*,Common/*}.swift"
|
||||
end
|
||||
|
||||
s.subspec 'BZip2' do |sp|
|
||||
sp.source_files = 'Sources/{BZip2/*,Common/*}.swift'
|
||||
sp.pod_target_xcconfig = { 'OTHER_SWIFT_FLAGS' => '-DSWCOMPRESSION_POD_BZ2' }
|
||||
s.subspec "BZip2" do |sp|
|
||||
sp.source_files = "Sources/{BZip2/*,Common/*}.swift"
|
||||
sp.pod_target_xcconfig = { "OTHER_SWIFT_FLAGS" => "-DSWCOMPRESSION_POD_BZ2" }
|
||||
end
|
||||
|
||||
s.subspec 'LZMA' do |sp|
|
||||
sp.source_files = 'Sources/{LZMA/*,Common/*}.swift'
|
||||
sp.pod_target_xcconfig = { 'OTHER_SWIFT_FLAGS' => '-DSWCOMPRESSION_POD_LZMA' }
|
||||
s.subspec "LZMA" do |sp|
|
||||
sp.source_files = "Sources/{LZMA/*,Common/*}.swift"
|
||||
sp.pod_target_xcconfig = { "OTHER_SWIFT_FLAGS" => "-DSWCOMPRESSION_POD_LZMA" }
|
||||
end
|
||||
|
||||
s.subspec 'LZMA2' do |sp|
|
||||
sp.dependency 'SWCompression/LZMA'
|
||||
sp.source_files = 'Sources/{LZMA2/*,Common/*}.swift'
|
||||
s.subspec "LZMA2" do |sp|
|
||||
sp.dependency "SWCompression/LZMA"
|
||||
sp.source_files = "Sources/{LZMA2/*,Common/*}.swift"
|
||||
end
|
||||
|
||||
s.subspec 'XZ' do |sp|
|
||||
sp.dependency 'SWCompression/LZMA2'
|
||||
sp.source_files = 'Sources/{XZ/*,Common/*}.swift'
|
||||
s.subspec "XZ" do |sp|
|
||||
sp.dependency "SWCompression/LZMA2"
|
||||
sp.source_files = "Sources/{XZ/*,Common/*}.swift"
|
||||
end
|
||||
|
||||
s.subspec 'ZIP' do |sp|
|
||||
sp.dependency 'SWCompression/Deflate'
|
||||
sp.source_files = 'Sources/{Zip/*,Common/*,Common/Container/*}.swift'
|
||||
sp.pod_target_xcconfig = { 'OTHER_SWIFT_FLAGS' => '-DSWCOMPRESSION_POD_ZIP' }
|
||||
s.subspec "ZIP" do |sp|
|
||||
sp.dependency "SWCompression/Deflate"
|
||||
sp.source_files = "Sources/{Zip/*,Common/*,Common/Container/*}.swift"
|
||||
sp.pod_target_xcconfig = { "OTHER_SWIFT_FLAGS" => "-DSWCOMPRESSION_POD_ZIP" }
|
||||
end
|
||||
|
||||
s.subspec 'TAR' do |sp|
|
||||
sp.source_files = 'Sources/{TAR/*,Common/*,Common/Container/*}.swift'
|
||||
s.subspec "TAR" do |sp|
|
||||
sp.source_files = "Sources/{TAR/*,Common/*,Common/Container/*}.swift"
|
||||
end
|
||||
|
||||
s.subspec 'SevenZip' do |sp|
|
||||
sp.dependency 'SWCompression/LZMA2'
|
||||
sp.source_files = 'Sources/{7-Zip/*,Common/*,Common/Container/*}.swift'
|
||||
sp.pod_target_xcconfig = { 'OTHER_SWIFT_FLAGS' => '-DSWCOMPRESSION_POD_SEVENZIP' }
|
||||
s.subspec "SevenZip" do |sp|
|
||||
sp.dependency "SWCompression/LZMA2"
|
||||
sp.source_files = "Sources/{7-Zip/*,Common/*,Common/Container/*}.swift"
|
||||
sp.pod_target_xcconfig = { "OTHER_SWIFT_FLAGS" => "-DSWCOMPRESSION_POD_SEVENZIP" }
|
||||
end
|
||||
|
||||
end
|
||||
@@ -15,9 +15,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>4.2.2</string>
|
||||
<string>4.3.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>59</string>
|
||||
<string>62</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2018 Timofey Solomko. All rights reserved.</string>
|
||||
</dict>
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>4.2.2</string>
|
||||
<string>4.3.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>59</string>
|
||||
<string>62</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -3,10 +3,11 @@
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 48;
|
||||
objectVersion = 50;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
0606CF8120641209002B6EE9 /* StandardExtraFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0606CF8020641209002B6EE9 /* StandardExtraFields.swift */; };
|
||||
06092A1A1FA4CB0300DE9FD5 /* CompressionMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06092A191FA4CB0300DE9FD5 /* CompressionMethod.swift */; };
|
||||
06092A241FA4CC3D00DE9FD5 /* CompressionMethod+Zip.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06092A231FA4CC3D00DE9FD5 /* CompressionMethod+Zip.swift */; };
|
||||
061C06211F0E89D900832F0C /* XZError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 061C06201F0E89D900832F0C /* XZError.swift */; };
|
||||
@@ -37,6 +38,7 @@
|
||||
06393DF51F1A7F8E00A647A0 /* ZipString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06393DF41F1A7F8E00A647A0 /* ZipString.swift */; };
|
||||
063DF10D1DE1F07800F38082 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 063DF1061DE1F07800F38082 /* Extensions.swift */; };
|
||||
063DF1131DE1F07800F38082 /* DecodingHuffmanTree.swift in Sources */ = {isa = PBXBuildFile; fileRef = 063DF1081DE1F07800F38082 /* DecodingHuffmanTree.swift */; };
|
||||
0642998B206017590044BA0C /* ZipExtraField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0642998A206017590044BA0C /* ZipExtraField.swift */; };
|
||||
064512871F82CE63006490BA /* 7zCoder+Equatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 064512861F82CE63006490BA /* 7zCoder+Equatable.swift */; };
|
||||
064F72241F1E5D4400017297 /* 7zContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 064F72231F1E5D4400017297 /* 7zContainer.swift */; };
|
||||
064F72291F1E638A00017297 /* 7zError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 064F72281F1E638A00017297 /* 7zError.swift */; };
|
||||
@@ -83,12 +85,14 @@
|
||||
06CDFCA81F111D9700292758 /* DeflateError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06CDFCA71F111D9700292758 /* DeflateError.swift */; };
|
||||
06CDFCAD1F111DBE00292758 /* LZMAError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06CDFCAC1F111DBE00292758 /* LZMAError.swift */; };
|
||||
06CDFCB21F111DEC00292758 /* LZMA2Error.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06CDFCB11F111DEC00292758 /* LZMA2Error.swift */; };
|
||||
06CFF6B22078C5A5003B8375 /* TarEntryInfoProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06CFF6B12078C5A5003B8375 /* TarEntryInfoProvider.swift */; };
|
||||
06D42DA52067B46800C1A98B /* test_custom_extra_field.zip in Resources */ = {isa = PBXBuildFile; fileRef = 06D42DA42067B46800C1A98B /* test_custom_extra_field.zip */; };
|
||||
06D42DA72067B71000C1A98B /* TestZipExtraField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06D42DA62067B71000C1A98B /* TestZipExtraField.swift */; };
|
||||
06D95AC11F4C54E0006B46AC /* BZip2+Compress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06D95AC01F4C54E0006B46AC /* BZip2+Compress.swift */; };
|
||||
06DDB1711F8190D400035BEF /* BZip2+BlockSize.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06DDB1701F8190D400035BEF /* BZip2+BlockSize.swift */; };
|
||||
06DE29B81FB7024C0098A761 /* ByteReader+ZipString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06DE29B71FB7024C0098A761 /* ByteReader+ZipString.swift */; };
|
||||
06E2346C1E068E9600F18798 /* XZArchive.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06E2346B1E068E9600F18798 /* XZArchive.swift */; };
|
||||
06E234821E06A6C200F18798 /* CheckSums.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06E234811E06A6C200F18798 /* CheckSums.swift */; };
|
||||
06E30F391F82D2DD00F80167 /* HuffmanLength+Comparable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06E30F381F82D2DD00F80167 /* HuffmanLength+Comparable.swift */; };
|
||||
06E6A6391F5C0FBB00D04856 /* HuffmanLength.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06E6A6381F5C0FBB00D04856 /* HuffmanLength.swift */; };
|
||||
06F0659A1FFB761600312A82 /* SWCompression.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06BE1AC81DB410F100EE0F59 /* SWCompression.framework */; };
|
||||
06F066131FFB763300312A82 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06F065A11FFB763300312A82 /* Constants.swift */; };
|
||||
@@ -204,6 +208,7 @@
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
0606CF8020641209002B6EE9 /* StandardExtraFields.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandardExtraFields.swift; sourceTree = "<group>"; };
|
||||
06092A191FA4CB0300DE9FD5 /* CompressionMethod.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompressionMethod.swift; sourceTree = "<group>"; };
|
||||
06092A231FA4CC3D00DE9FD5 /* CompressionMethod+Zip.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CompressionMethod+Zip.swift"; sourceTree = "<group>"; };
|
||||
061C06201F0E89D900832F0C /* XZError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XZError.swift; sourceTree = "<group>"; };
|
||||
@@ -236,6 +241,7 @@
|
||||
06393DF41F1A7F8E00A647A0 /* ZipString.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZipString.swift; sourceTree = "<group>"; };
|
||||
063DF1061DE1F07800F38082 /* Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Extensions.swift; path = Sources/Common/Extensions.swift; sourceTree = SOURCE_ROOT; };
|
||||
063DF1081DE1F07800F38082 /* DecodingHuffmanTree.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DecodingHuffmanTree.swift; path = Sources/Common/DecodingHuffmanTree.swift; sourceTree = SOURCE_ROOT; };
|
||||
0642998A206017590044BA0C /* ZipExtraField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZipExtraField.swift; sourceTree = "<group>"; };
|
||||
064492581DC606D400F10981 /* ZlibArchive.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZlibArchive.swift; sourceTree = "<group>"; };
|
||||
064512861F82CE63006490BA /* 7zCoder+Equatable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "7zCoder+Equatable.swift"; sourceTree = "<group>"; };
|
||||
064F72231F1E5D4400017297 /* 7zContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = 7zContainer.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
|
||||
@@ -280,12 +286,14 @@
|
||||
06CDFCA71F111D9700292758 /* DeflateError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeflateError.swift; sourceTree = "<group>"; };
|
||||
06CDFCAC1F111DBE00292758 /* LZMAError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LZMAError.swift; sourceTree = "<group>"; };
|
||||
06CDFCB11F111DEC00292758 /* LZMA2Error.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LZMA2Error.swift; sourceTree = "<group>"; };
|
||||
06CFF6B12078C5A5003B8375 /* TarEntryInfoProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TarEntryInfoProvider.swift; sourceTree = "<group>"; };
|
||||
06D42DA42067B46800C1A98B /* test_custom_extra_field.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = test_custom_extra_field.zip; sourceTree = "<group>"; };
|
||||
06D42DA62067B71000C1A98B /* TestZipExtraField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestZipExtraField.swift; sourceTree = "<group>"; };
|
||||
06D95AC01F4C54E0006B46AC /* BZip2+Compress.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "BZip2+Compress.swift"; sourceTree = "<group>"; };
|
||||
06DDB1701F8190D400035BEF /* BZip2+BlockSize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BZip2+BlockSize.swift"; sourceTree = "<group>"; };
|
||||
06DE29B71FB7024C0098A761 /* ByteReader+ZipString.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ByteReader+ZipString.swift"; sourceTree = "<group>"; };
|
||||
06E2346B1E068E9600F18798 /* XZArchive.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XZArchive.swift; sourceTree = "<group>"; };
|
||||
06E234811E06A6C200F18798 /* CheckSums.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CheckSums.swift; path = Sources/Common/CheckSums.swift; sourceTree = SOURCE_ROOT; };
|
||||
06E30F381F82D2DD00F80167 /* HuffmanLength+Comparable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "HuffmanLength+Comparable.swift"; path = "Sources/Common/HuffmanLength+Comparable.swift"; sourceTree = SOURCE_ROOT; };
|
||||
06E6A6381F5C0FBB00D04856 /* HuffmanLength.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = HuffmanLength.swift; path = Sources/Common/HuffmanLength.swift; sourceTree = SOURCE_ROOT; };
|
||||
06F065951FFB761600312A82 /* TestSWCompression.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TestSWCompression.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
06F065A11FFB763300312A82 /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
|
||||
@@ -428,7 +436,6 @@
|
||||
06092A191FA4CB0300DE9FD5 /* CompressionMethod.swift */,
|
||||
0686A63A1FA4C07D00E89C9E /* FileSystemType.swift */,
|
||||
06E6A6381F5C0FBB00D04856 /* HuffmanLength.swift */,
|
||||
06E30F381F82D2DD00F80167 /* HuffmanLength+Comparable.swift */,
|
||||
063DF1081DE1F07800F38082 /* DecodingHuffmanTree.swift */,
|
||||
06FEAD911F54B9CD00AD016E /* EncodingHuffmanTree.swift */,
|
||||
);
|
||||
@@ -560,6 +567,8 @@
|
||||
067518351E2A86F700D16354 /* ZipContainer.swift */,
|
||||
061C06411F0E8AD500832F0C /* ZipEntry.swift */,
|
||||
06BAC5931F8CFF28002443F4 /* ZipEntryInfo.swift */,
|
||||
0642998A206017590044BA0C /* ZipExtraField.swift */,
|
||||
0606CF8020641209002B6EE9 /* StandardExtraFields.swift */,
|
||||
061C063C1F0E8AB700832F0C /* ZipError.swift */,
|
||||
06393DF41F1A7F8E00A647A0 /* ZipString.swift */,
|
||||
061C064C1F0E901C00832F0C /* ZipLocalHeader.swift */,
|
||||
@@ -582,6 +591,7 @@
|
||||
061C06561F0E90C800832F0C /* TarError.swift */,
|
||||
0651FEC11F8E2E9100C49646 /* ContainerEntryType+Tar.swift */,
|
||||
0656B82A1F8A979A00111605 /* ByteReader+Tar.swift */,
|
||||
06CFF6B12078C5A5003B8375 /* TarEntryInfoProvider.swift */,
|
||||
);
|
||||
path = TAR;
|
||||
sourceTree = "<group>";
|
||||
@@ -623,6 +633,7 @@
|
||||
06F065A61FFB763300312A82 /* TarTests.swift */,
|
||||
06F065A91FFB763300312A82 /* XzTests.swift */,
|
||||
06F065A41FFB763300312A82 /* ZipTests.swift */,
|
||||
06D42DA62067B71000C1A98B /* TestZipExtraField.swift */,
|
||||
06F065A31FFB763300312A82 /* ZlibTests.swift */,
|
||||
);
|
||||
path = Tests;
|
||||
@@ -717,6 +728,7 @@
|
||||
06F065DB1FFB763300312A82 /* test_empty_cont.zip */,
|
||||
06F065DC1FFB763300312A82 /* SWCompressionSourceCode.zip */,
|
||||
06F065DD1FFB763300312A82 /* test_zip64.zip */,
|
||||
06D42DA42067B46800C1A98B /* test_custom_extra_field.zip */,
|
||||
);
|
||||
path = ZIP;
|
||||
sourceTree = "<group>";
|
||||
@@ -854,7 +866,7 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0920;
|
||||
LastUpgradeCheck = 0920;
|
||||
LastUpgradeCheck = 0930;
|
||||
ORGANIZATIONNAME = "Timofey Solomko";
|
||||
TargetAttributes = {
|
||||
06BE1AC71DB410F100EE0F59 = {
|
||||
@@ -867,7 +879,7 @@
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 06BE1AC21DB410F100EE0F59 /* Build configuration list for PBXProject "SWCompression" */;
|
||||
compatibilityVersion = "Xcode 8.0";
|
||||
compatibilityVersion = "Xcode 9.3";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
@@ -965,6 +977,7 @@
|
||||
06F0665E1FFB763400312A82 /* test_empty_cont.7z in Resources */,
|
||||
06F066731FFB763400312A82 /* test3.bz2 in Resources */,
|
||||
06F066471FFB763400312A82 /* test_empty_cont.zip in Resources */,
|
||||
06D42DA52067B46800C1A98B /* test_custom_extra_field.zip in Resources */,
|
||||
06F0663E1FFB763400312A82 /* test6.xz in Resources */,
|
||||
06F0666D1FFB763400312A82 /* test_win.7z in Resources */,
|
||||
06F066571FFB763400312A82 /* test_empty_file.tar in Resources */,
|
||||
@@ -1042,8 +1055,8 @@
|
||||
069AC20D1E02DB1D0041AC13 /* LZMA.swift in Sources */,
|
||||
0686A6401FA4C18800E89C9E /* FileSystemType+Gzip.swift in Sources */,
|
||||
06A3933A1DE0709300182E12 /* ZlibArchive.swift in Sources */,
|
||||
06E30F391F82D2DD00F80167 /* HuffmanLength+Comparable.swift in Sources */,
|
||||
061C063D1F0E8AB700832F0C /* ZipError.swift in Sources */,
|
||||
0606CF8120641209002B6EE9 /* StandardExtraFields.swift in Sources */,
|
||||
0631CB061F81109E00A2E0AB /* Deflate+Constants.swift in Sources */,
|
||||
06D95AC11F4C54E0006B46AC /* BZip2+Compress.swift in Sources */,
|
||||
06912BD21F5C8F3D0070BB60 /* Deflate+Lengths.swift in Sources */,
|
||||
@@ -1064,6 +1077,7 @@
|
||||
0686A6451FA4C47300E89C9E /* FileSystemType+Zip.swift in Sources */,
|
||||
06CDFCA31F111D6C00292758 /* BZip2Error.swift in Sources */,
|
||||
06393DF51F1A7F8E00A647A0 /* ZipString.swift in Sources */,
|
||||
06CFF6B22078C5A5003B8375 /* TarEntryInfoProvider.swift in Sources */,
|
||||
06CC3FE21F8AAF3100BD576D /* ByteReader+XZ.swift in Sources */,
|
||||
065D0ADC1F2B9D9100CE2DA8 /* 7zEntryInfo.swift in Sources */,
|
||||
06F276DF1F2BAB4A00E67335 /* 7zEntry.swift in Sources */,
|
||||
@@ -1083,6 +1097,7 @@
|
||||
064F72291F1E638A00017297 /* 7zError.swift in Sources */,
|
||||
06CDFCAD1F111DBE00292758 /* LZMAError.swift in Sources */,
|
||||
06E6A6391F5C0FBB00D04856 /* HuffmanLength.swift in Sources */,
|
||||
0642998B206017590044BA0C /* ZipExtraField.swift in Sources */,
|
||||
0656B82B1F8A979A00111605 /* ByteReader+Tar.swift in Sources */,
|
||||
06B689581F278815007C9316 /* 7zProperty.swift in Sources */,
|
||||
0686A63B1FA4C07D00E89C9E /* FileSystemType.swift in Sources */,
|
||||
@@ -1101,6 +1116,7 @@
|
||||
06F066171FFB763300312A82 /* BZip2Tests.swift in Sources */,
|
||||
06F066181FFB763300312A82 /* TarTests.swift in Sources */,
|
||||
06F066191FFB763300312A82 /* GzipTests.swift in Sources */,
|
||||
06D42DA72067B71000C1A98B /* TestZipExtraField.swift in Sources */,
|
||||
06F0661D1FFB763300312A82 /* LzmaTests.swift in Sources */,
|
||||
06F0661B1FFB763300312A82 /* XzTests.swift in Sources */,
|
||||
06F0661E1FFB763300312A82 /* BZip2CompressionTests.swift in Sources */,
|
||||
@@ -1125,25 +1141,35 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CURRENT_PROJECT_VERSION = 59;
|
||||
CURRENT_PROJECT_VERSION = 62;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=appletvos*]" = "\"$(SRCROOT)/Carthage/Build/tvOS\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=appletvsimulator*]" = "\"$(SRCROOT)/Carthage/Build/tvOS\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*]" = "\"$(SRCROOT)/Carthage/Build/iOS\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*]" = "\"$(SRCROOT)/Carthage/Build/iOS\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=macosx*]" = "\"$(SRCROOT)/Carthage/Build/Mac\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=watchos*]" = "\"$(SRCROOT)/Carthage/Build/watchOS\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=watchsimulator*]" = "\"$(SRCROOT)/Carthage/Build/watchOS\"";
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
@@ -1155,8 +1181,11 @@
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
OTHER_LDFLAGS = (
|
||||
"-framework",
|
||||
BitByteData,
|
||||
);
|
||||
SDKROOT = macosx;
|
||||
STRIP_INSTALLED_PRODUCT = NO;
|
||||
SUPPORTED_PLATFORMS = "macosx watchsimulator iphonesimulator appletvsimulator watchos appletvos iphoneos";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
@@ -1169,24 +1198,34 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CURRENT_PROJECT_VERSION = 59;
|
||||
CURRENT_PROJECT_VERSION = 62;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=appletvos*]" = "\"$(SRCROOT)/Carthage/Build/tvOS\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=appletvsimulator*]" = "\"$(SRCROOT)/Carthage/Build/tvOS\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*]" = "\"$(SRCROOT)/Carthage/Build/iOS\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*]" = "\"$(SRCROOT)/Carthage/Build/iOS\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=macosx*]" = "\"$(SRCROOT)/Carthage/Build/Mac\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=watchos*]" = "\"$(SRCROOT)/Carthage/Build/watchOS\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=watchsimulator*]" = "\"$(SRCROOT)/Carthage/Build/watchOS\"";
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
@@ -1196,10 +1235,13 @@
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
OTHER_LDFLAGS = (
|
||||
"-framework",
|
||||
BitByteData,
|
||||
);
|
||||
SDKROOT = macosx;
|
||||
STRIP_INSTALLED_PRODUCT = NO;
|
||||
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
||||
@@ -1212,18 +1254,17 @@
|
||||
APPLICATION_EXTENSION_API_ONLY = YES;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 59;
|
||||
DYLIB_CURRENT_VERSION = 62;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=appletvos*]" = "\"$(SRCROOT)/Carthage/Build/tvOS\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=appletvsimulator*]" = "\"$(SRCROOT)/Carthage/Build/tvOS\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*]" = "\"$(SRCROOT)/Carthage/Build/iOS\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*]" = "\"$(SRCROOT)/Carthage/Build/iOS\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=macosx*]" = "\"$(SRCROOT)/Carthage/Build/Mac\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=watchos*]" = "\"$(SRCROOT)/Carthage/Build/watchOS\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=watchsimulator*]" = "\"$(SRCROOT)/Carthage/Build/watchOS\"";
|
||||
INFOPLIST_FILE = SWCompression.xcodeproj/SWCompression.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @loader_path/Frameworks @executable_path/Frameworks @loader_path/../Frameworks @executable_path/../Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@loader_path/Frameworks",
|
||||
"@executable_path/Frameworks",
|
||||
"@loader_path/../Frameworks",
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
OTHER_LDFLAGS = (
|
||||
"-framework",
|
||||
BitByteData,
|
||||
@@ -1241,18 +1282,17 @@
|
||||
APPLICATION_EXTENSION_API_ONLY = YES;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 59;
|
||||
DYLIB_CURRENT_VERSION = 62;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=appletvos*]" = "\"$(SRCROOT)/Carthage/Build/tvOS\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=appletvsimulator*]" = "\"$(SRCROOT)/Carthage/Build/tvOS\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*]" = "\"$(SRCROOT)/Carthage/Build/iOS\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*]" = "\"$(SRCROOT)/Carthage/Build/iOS\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=macosx*]" = "\"$(SRCROOT)/Carthage/Build/Mac\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=watchos*]" = "\"$(SRCROOT)/Carthage/Build/watchOS\"";
|
||||
"FRAMEWORK_SEARCH_PATHS[sdk=watchsimulator*]" = "\"$(SRCROOT)/Carthage/Build/watchOS\"";
|
||||
INFOPLIST_FILE = SWCompression.xcodeproj/SWCompression.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @loader_path/Frameworks @executable_path/Frameworks @loader_path/../Frameworks @executable_path/../Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@loader_path/Frameworks",
|
||||
"@executable_path/Frameworks",
|
||||
"@loader_path/../Frameworks",
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
OTHER_LDFLAGS = (
|
||||
"-framework",
|
||||
BitByteData,
|
||||
@@ -1269,7 +1309,13 @@
|
||||
buildSettings = {
|
||||
COPY_PHASE_STRIP = NO;
|
||||
INFOPLIST_FILE = SWCompression.xcodeproj/TestSWCompression.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @loader_path/Frameworks @executable_path/Frameworks @loader_path/../Frameworks @executable_path/../Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@loader_path/Frameworks",
|
||||
"@executable_path/Frameworks",
|
||||
"@loader_path/../Frameworks",
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = me.tsolomko.TestSWCompression;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 4.0;
|
||||
@@ -1281,7 +1327,13 @@
|
||||
buildSettings = {
|
||||
COPY_PHASE_STRIP = NO;
|
||||
INFOPLIST_FILE = SWCompression.xcodeproj/TestSWCompression.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @loader_path/Frameworks @executable_path/Frameworks @loader_path/../Frameworks @executable_path/../Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@loader_path/Frameworks",
|
||||
"@executable_path/Frameworks",
|
||||
"@loader_path/../Frameworks",
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = me.tsolomko.TestSWCompression;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 4.0;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>BuildSystemType</key>
|
||||
<string>Latest</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0920"
|
||||
LastUpgradeVersion = "0930"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -26,7 +26,6 @@
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
@@ -56,7 +55,6 @@
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
|
||||
@@ -54,8 +54,7 @@ class SevenZipCoderInfo {
|
||||
type = bitReader.byte()
|
||||
}
|
||||
|
||||
if type != 0x00 {
|
||||
throw SevenZipError.internalStructureError
|
||||
}
|
||||
guard type == 0x00
|
||||
else { throw SevenZipError.internalStructureError }
|
||||
}
|
||||
}
|
||||
@@ -55,110 +55,108 @@ public class SevenZipContainer: Container {
|
||||
let byteReader = ByteReader(data: data)
|
||||
|
||||
for file in files {
|
||||
let info: SevenZipEntryInfo
|
||||
let data: Data?
|
||||
if file.isEmptyStream {
|
||||
let info = file.isEmptyFile && !file.isAntiFile ? SevenZipEntryInfo(file, 0) : SevenZipEntryInfo(file)
|
||||
let data = file.isEmptyFile && !file.isAntiFile ? Data() : nil
|
||||
entries.append(SevenZipEntry(info, data))
|
||||
continue
|
||||
}
|
||||
|
||||
if !file.isEmptyStream {
|
||||
// Without `SevenZipStreamInfo` and `SevenZipPackInfo` we cannot find file data in container.
|
||||
guard let streamInfo = header.mainStreams,
|
||||
let packInfo = streamInfo.packInfo
|
||||
else { throw SevenZipError.internalStructureError }
|
||||
// Without `SevenZipStreamInfo` and `SevenZipPackInfo` we cannot find file data in container.
|
||||
guard let streamInfo = header.mainStreams,
|
||||
let packInfo = streamInfo.packInfo
|
||||
else { throw SevenZipError.internalStructureError }
|
||||
|
||||
// SubstreamInfo is required to get files' data, and without it we can only return files' info.
|
||||
guard let substreamInfo = streamInfo.substreamInfo else {
|
||||
entries.append(SevenZipEntry(SevenZipEntryInfo(file), nil))
|
||||
continue
|
||||
// SubstreamInfo is required to get files' data, and without it we can only return files' info.
|
||||
guard let substreamInfo = streamInfo.substreamInfo else {
|
||||
entries.append(SevenZipEntry(SevenZipEntryInfo(file), nil))
|
||||
continue
|
||||
}
|
||||
|
||||
// Check if there is enough folders.
|
||||
guard folderIndex < streamInfo.coderInfo.numFolders
|
||||
else { throw SevenZipError.internalStructureError }
|
||||
|
||||
/// Folder which contains current file.
|
||||
let folder = streamInfo.coderInfo.folders[folderIndex]
|
||||
|
||||
// There may be several streams in a single folder, so we have to iterate over them, if necessary.
|
||||
// If we switched folders or completed reading of a stream we need to move to the next stream.
|
||||
if folderFileIndex == 0 || unpackedStreamData.isFinished {
|
||||
streamIndex += 1
|
||||
|
||||
// First, we move to the stream's offset. We don't have any guarantees that streams will be
|
||||
// enountered in the same order, as they are placed in the container. Thus, we have to start moving
|
||||
// to stream's offset from the beginning.
|
||||
// TODO: Is this correct or the order of streams is guaranteed?
|
||||
byteReader.offset = signatureHeaderSize + packInfo.packPosition // Pack offset.
|
||||
if streamIndex != 0 {
|
||||
for i in 0..<streamIndex {
|
||||
byteReader.offset += packInfo.packSizes[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Check if there is enough folders.
|
||||
guard folderIndex < streamInfo.coderInfo.numFolders
|
||||
else { throw SevenZipError.internalStructureError }
|
||||
// Load the stream.
|
||||
let streamData = Data(bytes: byteReader.bytes(count: packInfo.packSizes[streamIndex]))
|
||||
|
||||
/// Folder which contains current file.
|
||||
let folder = streamInfo.coderInfo.folders[folderIndex]
|
||||
|
||||
// There may be several streams in a single folder, so we have to iterate over them, if necessary.
|
||||
// If we switched folders or completed reading of a stream we need to move to the next stream.
|
||||
if folderFileIndex == 0 || unpackedStreamData.isFinished {
|
||||
streamIndex += 1
|
||||
|
||||
// First, we move to the stream's offset. We don't have any guarantees that streams will be
|
||||
// enountered in the same order, as they are placed in the container. Thus, we have to start moving
|
||||
// to stream's offset from the beginning.
|
||||
// TODO: Is this correct or the order of streams is guaranteed?
|
||||
byteReader.offset = signatureHeaderSize + packInfo.packPosition // Pack offset.
|
||||
if streamIndex != 0 {
|
||||
for i in 0..<streamIndex {
|
||||
byteReader.offset += packInfo.packSizes[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Load the stream.
|
||||
let streamData = Data(bytes: byteReader.bytes(count: packInfo.packSizes[streamIndex]))
|
||||
|
||||
// Check stream's CRC, if it's available.
|
||||
if streamIndex < packInfo.digests.count,
|
||||
let storedStreamCRC = packInfo.digests[streamIndex] {
|
||||
guard CheckSums.crc32(streamData) == storedStreamCRC
|
||||
else { throw SevenZipError.wrongCRC }
|
||||
}
|
||||
|
||||
// One stream can contain data for several files, so we need to decode the stream first, then split
|
||||
// it into files.
|
||||
unpackedStreamData = ByteReader(data: try folder.unpack(data: streamData))
|
||||
}
|
||||
|
||||
// `SevenZipSubstreamInfo` object must contain information about file's size and may also contain
|
||||
// information about file's CRC32.
|
||||
|
||||
// File's unpacked size is required to proceed.
|
||||
guard nonEmptyFileIndex < substreamInfo.unpackSizes.count
|
||||
else { throw SevenZipError.internalStructureError }
|
||||
let fileSize = substreamInfo.unpackSizes[nonEmptyFileIndex]
|
||||
|
||||
// Check, if we aren't about to read too much from a stream.
|
||||
guard unpackedStreamData.offset + fileSize <= unpackedStreamData.data.endIndex
|
||||
else { throw SevenZipError.internalStructureError }
|
||||
let fileData = Data(bytes: unpackedStreamData.bytes(count: fileSize))
|
||||
|
||||
let calculatedFileCRC = CheckSums.crc32(fileData)
|
||||
if nonEmptyFileIndex < substreamInfo.digests.count {
|
||||
guard calculatedFileCRC == substreamInfo.digests[nonEmptyFileIndex]
|
||||
// Check stream's CRC, if it's available.
|
||||
if streamIndex < packInfo.digests.count,
|
||||
let storedStreamCRC = packInfo.digests[streamIndex] {
|
||||
guard CheckSums.crc32(streamData) == storedStreamCRC
|
||||
else { throw SevenZipError.wrongCRC }
|
||||
}
|
||||
|
||||
info = SevenZipEntryInfo(file, fileSize, calculatedFileCRC)
|
||||
data = fileData
|
||||
|
||||
// Update folder's crc and unpack size.
|
||||
folderUnpackSize += fileSize
|
||||
folderCRC = CheckSums.crc32(fileData, prevValue: folderCRC)
|
||||
|
||||
folderFileIndex += 1
|
||||
nonEmptyFileIndex += 1
|
||||
|
||||
if folderFileIndex >= folder.numUnpackSubstreams { // If we read all files in folder...
|
||||
// Check folder's unpacked size as well as its CRC32 (if it is available).
|
||||
guard folderUnpackSize == folder.unpackSize()
|
||||
else { throw SevenZipError.wrongSize }
|
||||
if let storedFolderCRC = folder.crc {
|
||||
guard folderCRC == storedFolderCRC
|
||||
else { throw SevenZipError.wrongCRC }
|
||||
}
|
||||
// Reset folder's unpack size and CRC32.
|
||||
folderCRC = CheckSums.crc32(Data())
|
||||
folderUnpackSize = 0
|
||||
// Reset file index for the next folder.
|
||||
folderFileIndex = 0
|
||||
// Move to the next folder.
|
||||
folderIndex += 1
|
||||
}
|
||||
} else {
|
||||
info = file.isEmptyFile && !file.isAntiFile ? SevenZipEntryInfo(file, 0) : SevenZipEntryInfo(file)
|
||||
data = file.isEmptyFile && !file.isAntiFile ? Data() : nil
|
||||
// One stream can contain data for several files, so we need to decode the stream first, then split
|
||||
// it into files.
|
||||
unpackedStreamData = ByteReader(data: try folder.unpack(data: streamData))
|
||||
}
|
||||
|
||||
// `SevenZipSubstreamInfo` object must contain information about file's size and may also contain
|
||||
// information about file's CRC32.
|
||||
|
||||
// File's unpacked size is required to proceed.
|
||||
guard nonEmptyFileIndex < substreamInfo.unpackSizes.count
|
||||
else { throw SevenZipError.internalStructureError }
|
||||
let fileSize = substreamInfo.unpackSizes[nonEmptyFileIndex]
|
||||
|
||||
// Check, if we aren't about to read too much from a stream.
|
||||
guard fileSize <= unpackedStreamData.bytesLeft
|
||||
else { throw SevenZipError.internalStructureError }
|
||||
let fileData = Data(bytes: unpackedStreamData.bytes(count: fileSize))
|
||||
|
||||
let calculatedFileCRC = CheckSums.crc32(fileData)
|
||||
if nonEmptyFileIndex < substreamInfo.digests.count {
|
||||
guard calculatedFileCRC == substreamInfo.digests[nonEmptyFileIndex]
|
||||
else { throw SevenZipError.wrongCRC }
|
||||
}
|
||||
|
||||
let info = SevenZipEntryInfo(file, fileSize, calculatedFileCRC)
|
||||
let data = fileData
|
||||
entries.append(SevenZipEntry(info, data))
|
||||
|
||||
// Update folder's crc and unpack size.
|
||||
folderUnpackSize += fileSize
|
||||
folderCRC = CheckSums.crc32(fileData, prevValue: folderCRC)
|
||||
|
||||
folderFileIndex += 1
|
||||
nonEmptyFileIndex += 1
|
||||
|
||||
if folderFileIndex >= folder.numUnpackSubstreams { // If we read all files in folder...
|
||||
// Check folder's unpacked size as well as its CRC32 (if it is available).
|
||||
guard folderUnpackSize == folder.unpackSize()
|
||||
else { throw SevenZipError.wrongSize }
|
||||
if let storedFolderCRC = folder.crc {
|
||||
guard folderCRC == storedFolderCRC
|
||||
else { throw SevenZipError.wrongCRC }
|
||||
}
|
||||
// Reset folder's unpack size and CRC32.
|
||||
folderCRC = CheckSums.crc32(Data())
|
||||
folderUnpackSize = 0
|
||||
// Reset file index for the next folder.
|
||||
folderFileIndex = 0
|
||||
// Move to the next folder.
|
||||
folderIndex += 1
|
||||
}
|
||||
}
|
||||
|
||||
return entries
|
||||
@@ -220,8 +218,8 @@ public class SevenZipContainer: Container {
|
||||
let startHeaderCRC = bitReader.uint32()
|
||||
|
||||
/// - Note: Relative to SignatureHeader
|
||||
let nextHeaderOffset = bitReader.uint64().toInt()
|
||||
let nextHeaderSize = bitReader.uint64().toInt()
|
||||
let nextHeaderOffset = bitReader.int(fromBytes: 8)
|
||||
let nextHeaderSize = bitReader.int(fromBytes: 8)
|
||||
let nextHeaderCRC = bitReader.uint32()
|
||||
|
||||
bitReader.offset = 12
|
||||
|
||||
@@ -57,9 +57,9 @@ public struct SevenZipEntryInfo: ContainerEntryInfo {
|
||||
|
||||
self.name = file.name
|
||||
|
||||
self.accessTime = Date(file.aTime)
|
||||
self.creationTime = Date(file.cTime)
|
||||
self.modificationTime = Date(file.mTime)
|
||||
self.accessTime = file.aTime
|
||||
self.creationTime = file.cTime
|
||||
self.modificationTime = file.mTime
|
||||
|
||||
self.winAttributes = file.winAttributes
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ class SevenZipFileInfo {
|
||||
var isEmptyFile = false
|
||||
var isAntiFile = false
|
||||
var name: String = ""
|
||||
var cTime: UInt64?
|
||||
var mTime: UInt64?
|
||||
var aTime: UInt64?
|
||||
var cTime: Date?
|
||||
var mTime: Date?
|
||||
var aTime: Date?
|
||||
var winAttributes: UInt32?
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ class SevenZipFileInfo {
|
||||
else { throw SevenZipError.externalNotSupported }
|
||||
|
||||
for i in 0..<numFiles where timesDefined[i] == 1 {
|
||||
files[i].cTime = bitReader.uint64()
|
||||
files[i].cTime = Date(bitReader.uint64())
|
||||
}
|
||||
case 0x13: // Access time
|
||||
let timesDefined = bitReader.defBits(count: numFiles)
|
||||
@@ -89,7 +89,7 @@ class SevenZipFileInfo {
|
||||
else { throw SevenZipError.externalNotSupported }
|
||||
|
||||
for i in 0..<numFiles where timesDefined[i] == 1 {
|
||||
files[i].aTime = bitReader.uint64()
|
||||
files[i].aTime = Date(bitReader.uint64())
|
||||
}
|
||||
case 0x14: // Modification time
|
||||
let timesDefined = bitReader.defBits(count: numFiles)
|
||||
@@ -100,7 +100,7 @@ class SevenZipFileInfo {
|
||||
else { throw SevenZipError.externalNotSupported }
|
||||
|
||||
for i in 0..<numFiles where timesDefined[i] == 1 {
|
||||
files[i].mTime = bitReader.uint64()
|
||||
files[i].mTime = Date(bitReader.uint64())
|
||||
}
|
||||
case 0x15: // WinAttributes
|
||||
let attributesDefined = bitReader.defBits(count: numFiles)
|
||||
|
||||
@@ -39,6 +39,10 @@ class SevenZipFolder {
|
||||
// This property is stored in SubstreamInfo.
|
||||
var numUnpackSubstreams = 1
|
||||
|
||||
lazy var orderedCompressionMethods: [CompressionMethod] = {
|
||||
self.orderedCoders().map { $0.compressionMethod }
|
||||
}()
|
||||
|
||||
init(_ bitReader: MsbBitReader) throws {
|
||||
numCoders = bitReader.szMbd()
|
||||
for _ in 0..<numCoders {
|
||||
|
||||
@@ -35,9 +35,8 @@ class SevenZipHeader {
|
||||
type = bitReader.byte()
|
||||
}
|
||||
|
||||
if type != 0x00 {
|
||||
throw SevenZipError.internalStructureError
|
||||
}
|
||||
guard type == 0x00
|
||||
else { throw SevenZipError.internalStructureError }
|
||||
}
|
||||
|
||||
convenience init(_ bitReader: MsbBitReader, using streamInfo: SevenZipStreamInfo) throws {
|
||||
|
||||
@@ -41,9 +41,8 @@ class SevenZipPackInfo {
|
||||
type = bitReader.byte()
|
||||
}
|
||||
|
||||
if type != 0x00 {
|
||||
throw SevenZipError.internalStructureError
|
||||
}
|
||||
guard type == 0x00
|
||||
else { throw SevenZipError.internalStructureError }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,9 +32,8 @@ class SevenZipStreamInfo {
|
||||
type = bitReader.byte()
|
||||
}
|
||||
|
||||
if type != 0x00 {
|
||||
throw SevenZipError.internalStructureError
|
||||
}
|
||||
guard type == 0x00
|
||||
else { throw SevenZipError.internalStructureError }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -80,9 +80,8 @@ class SevenZipSubstreamInfo {
|
||||
type = bitReader.byte()
|
||||
}
|
||||
|
||||
if type != 0x00 {
|
||||
throw SevenZipError.internalStructureError
|
||||
}
|
||||
guard type == 0x00
|
||||
else { throw SevenZipError.internalStructureError }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -269,9 +269,9 @@ extension BZip2: CompressionAlgorithm {
|
||||
}
|
||||
if (byte == 0 && i == array.count - 1) || byte != 0 {
|
||||
if lengthOfZerosRun > 0 {
|
||||
let digitsNumber = floor(log2(Double(lengthOfZerosRun) + 1))
|
||||
let digitsNumber = Int(floor(log2(Double(lengthOfZerosRun) + 1)))
|
||||
var remainder = lengthOfZerosRun
|
||||
for _ in 0..<Int(digitsNumber) {
|
||||
for _ in 0..<digitsNumber {
|
||||
let quotient = Int(ceil(Double(remainder) / 2) - 1)
|
||||
let digit = remainder - quotient * 2
|
||||
if digit == 1 {
|
||||
|
||||
@@ -41,9 +41,9 @@ public class BZip2: DecompressionAlgorithm {
|
||||
var totalCRC: UInt32 = 0
|
||||
while true {
|
||||
// Using `Int64` because 48 bits may not fit into `Int` on some platforms.
|
||||
let blockType = Int64(bitReader.int(fromBits: 48))
|
||||
let blockType = bitReader.uint64(fromBits: 48)
|
||||
|
||||
let blockCRC32 = UInt32(truncatingIfNeeded: bitReader.int(fromBits: 32))
|
||||
let blockCRC32 = bitReader.uint32(fromBits: 32)
|
||||
|
||||
if blockType == 0x314159265359 {
|
||||
let blockData = try decode(bitReader, blockSize)
|
||||
|
||||
@@ -8,6 +8,7 @@ import Foundation
|
||||
/// A type that represents a container with files, directories and/or other data.
|
||||
public protocol Container {
|
||||
|
||||
/// A type that represents an entry from this container.
|
||||
associatedtype Entry: ContainerEntry
|
||||
|
||||
/// Retrieve all container entries with their data.
|
||||
|
||||
@@ -8,6 +8,7 @@ import Foundation
|
||||
/// A type that represents an entry from the container with its data and information.
|
||||
public protocol ContainerEntry {
|
||||
|
||||
/// A type that provides information about an entry.
|
||||
associatedtype Info: ContainerEntryInfo
|
||||
|
||||
/// Provides access to information about the entry.
|
||||
|
||||
@@ -8,9 +8,9 @@ import BitByteData
|
||||
|
||||
class DecodingHuffmanTree {
|
||||
|
||||
private var bitReader: BitReader
|
||||
private let bitReader: BitReader
|
||||
|
||||
private var tree: [Int]
|
||||
private let tree: [Int]
|
||||
private let leafCount: Int
|
||||
|
||||
/// `lengths` don't have to be properly sorted, but there must not be any 0 code lengths.
|
||||
@@ -22,7 +22,7 @@ class DecodingHuffmanTree {
|
||||
|
||||
// Calculate maximum amount of leaves possible in a tree.
|
||||
self.leafCount = 1 << (sortedLengths.last!.codeLength + 1)
|
||||
self.tree = Array(repeating: -1, count: leafCount)
|
||||
var tree = Array(repeating: -1, count: leafCount)
|
||||
|
||||
// Calculates symbols for each length in 'sortedLengths' array and put them in the tree.
|
||||
var loopBits = -1
|
||||
@@ -46,8 +46,9 @@ class DecodingHuffmanTree {
|
||||
index = bit == 0 ? 2 * index + 1 : 2 * index + 2
|
||||
treeCode >>= 1
|
||||
}
|
||||
self.tree[index] = length.symbol
|
||||
tree[index] = length.symbol
|
||||
}
|
||||
self.tree = tree
|
||||
}
|
||||
|
||||
func findNextSymbol() -> Int {
|
||||
|
||||
@@ -8,9 +8,9 @@ import BitByteData
|
||||
|
||||
class EncodingHuffmanTree {
|
||||
|
||||
private var bitWriter: BitWriter
|
||||
private let bitWriter: BitWriter
|
||||
|
||||
private var codingIndices: [[Int]]
|
||||
private let codingIndices: [[Int]]
|
||||
|
||||
/// `lengths` don't have to be properly sorted, but there must not be any 0 code lengths.
|
||||
/// If `reverseCodes` is true, then bit order of tree codes will be reversed. Necessary for Deflate.
|
||||
@@ -20,7 +20,7 @@ class EncodingHuffmanTree {
|
||||
// Sort `lengths` array to calculate canonical Huffman code.
|
||||
let sortedLengths = lengths.sorted()
|
||||
|
||||
self.codingIndices = Array(repeating: [-1, -1], count: sortedLengths.count)
|
||||
var codingIndices = Array(repeating: [-1, -1], count: sortedLengths.count)
|
||||
|
||||
// Calculates symbols for each length in 'sortedLengths' array and put them in the tree.
|
||||
var loopBits = -1
|
||||
@@ -36,8 +36,9 @@ class EncodingHuffmanTree {
|
||||
}
|
||||
// Then we reverse bit order of the symbol, if necessary.
|
||||
let treeCode = reverseCodes ? symbol.reversed(bits: loopBits) : symbol
|
||||
self.codingIndices[length.symbol] = [treeCode, bits]
|
||||
codingIndices[length.symbol] = [treeCode, bits]
|
||||
}
|
||||
self.codingIndices = codingIndices
|
||||
}
|
||||
|
||||
func code(symbol: Int) {
|
||||
|
||||
@@ -50,14 +50,10 @@ extension Date {
|
||||
private static let ntfsReferenceDate = DateComponents(calendar: Calendar(identifier: .iso8601),
|
||||
timeZone: TimeZone(abbreviation: "UTC"),
|
||||
year: 1601, month: 1, day: 1,
|
||||
hour: 0, minute: 0, second: 0).date
|
||||
hour: 0, minute: 0, second: 0).date!
|
||||
|
||||
init?(_ ntfsTime: UInt64?) {
|
||||
if let time = ntfsTime, let ntfsReferenceDate = Date.ntfsReferenceDate {
|
||||
self.init(timeInterval: TimeInterval(time) / 10_000_000, since: ntfsReferenceDate)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
init(_ ntfsTime: UInt64) {
|
||||
self.init(timeInterval: TimeInterval(ntfsTime) / 10_000_000, since: .ntfsReferenceDate)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
// Copyright (c) 2018 Timofey Solomko
|
||||
// Licensed under MIT License
|
||||
//
|
||||
// See LICENSE for license information
|
||||
|
||||
import Foundation
|
||||
|
||||
extension HuffmanLength: Comparable {
|
||||
|
||||
static func < (left: HuffmanLength, right: HuffmanLength) -> Bool {
|
||||
if left.codeLength == right.codeLength {
|
||||
return left.symbol < right.symbol
|
||||
} else {
|
||||
return left.codeLength < right.codeLength
|
||||
}
|
||||
}
|
||||
|
||||
static func == (left: HuffmanLength, right: HuffmanLength) -> Bool {
|
||||
return left.codeLength == right.codeLength && left.symbol == right.symbol
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,9 +5,21 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
struct HuffmanLength {
|
||||
struct HuffmanLength: Equatable {
|
||||
|
||||
let symbol: Int
|
||||
let codeLength: Int
|
||||
|
||||
}
|
||||
|
||||
extension HuffmanLength: Comparable {
|
||||
|
||||
static func < (left: HuffmanLength, right: HuffmanLength) -> Bool {
|
||||
if left.codeLength == right.codeLength {
|
||||
return left.symbol < right.symbol
|
||||
} else {
|
||||
return left.codeLength < right.codeLength
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class GzipArchive: Archive {
|
||||
bitReader.align()
|
||||
|
||||
let crc32 = bitReader.uint32()
|
||||
let isize = UInt64(truncatingIfNeeded: bitReader.uint32())
|
||||
let isize = bitReader.uint64(fromBytes: 4)
|
||||
guard UInt64(truncatingIfNeeded: memberData.count) % (UInt64(truncatingIfNeeded: 1) << 32) == isize
|
||||
else { throw GzipError.wrongISize }
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public class LZMA: DecompressionAlgorithm {
|
||||
|
||||
try decoder.setProperties(byteReader.byte())
|
||||
decoder.resetStateAndDecoders()
|
||||
decoder.dictionarySize = byteReader.uint32().toInt()
|
||||
decoder.dictionarySize = byteReader.int(fromBytes: 4)
|
||||
|
||||
let uncompSize = uncompressedSize ?? byteReader.uint64()
|
||||
if uncompSize == UInt64.max {
|
||||
|
||||
@@ -23,7 +23,7 @@ class LZMA2Decoder {
|
||||
func setDictionarySize(_ byte: UInt8) throws {
|
||||
guard byte & 0xC0 == 0
|
||||
else { throw LZMA2Error.wrongDictionarySize }
|
||||
let bits = byte & 0x3F
|
||||
let bits = (byte & 0x3F).toInt()
|
||||
guard bits < 40
|
||||
else { throw LZMA2Error.wrongDictionarySize }
|
||||
|
||||
@@ -31,8 +31,8 @@ class LZMA2Decoder {
|
||||
if bits == 40 {
|
||||
dictSize = UInt32.max
|
||||
} else {
|
||||
dictSize = UInt32(2 | (bits.toInt() & 1))
|
||||
dictSize <<= UInt32(bits.toInt() / 2 + 11)
|
||||
dictSize = UInt32(truncatingIfNeeded: 2 | (bits & 1))
|
||||
dictSize <<= UInt32(truncatingIfNeeded: bits / 2 + 11)
|
||||
}
|
||||
|
||||
self.decoder.dictionarySize = dictSize.toInt()
|
||||
|
||||
@@ -13,13 +13,11 @@ extension ByteReader {
|
||||
var buffer = [UInt8]()
|
||||
while offset - startIndex < cutoff {
|
||||
let byte = self.byte()
|
||||
if ends.contains(byte) {
|
||||
offset -= 1
|
||||
break
|
||||
}
|
||||
guard !ends.contains(byte)
|
||||
else { break }
|
||||
buffer.append(byte)
|
||||
}
|
||||
offset += cutoff - (offset - startIndex)
|
||||
offset = startIndex + cutoff
|
||||
return buffer
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,53 @@ import BitByteData
|
||||
/// Provides functions for work with TAR containers.
|
||||
public class TarContainer: Container {
|
||||
|
||||
/**
|
||||
Represents a "format" of TAR container: a minimal set of extensions to basic TAR format required to successfully
|
||||
read particular container.
|
||||
*/
|
||||
public enum Format {
|
||||
/// Pre POSIX format (aka "basic TAR format").
|
||||
case prePosix
|
||||
/// "UStar" format introduced by POSIX IEEE P1003.1 standard.
|
||||
case ustar
|
||||
/// "UStar"-like format with GNU extensions (e.g. special container entries for long file and link names).
|
||||
case gnu
|
||||
/// "PAX" format introduced by POSIX.1-2001 standard, a set of extensions to "UStar" format.
|
||||
case pax
|
||||
}
|
||||
|
||||
/**
|
||||
Processes TAR container and returns its "format": a minimal set of extensions to basic TAR format required to
|
||||
successfully read this container.
|
||||
|
||||
- Parameter container: TAR container's data.
|
||||
|
||||
- Throws: `TarError`, which may indicate that either container is damaged or it might not be TAR container at all.
|
||||
|
||||
- SeeAlso: `TarContainer.Format`
|
||||
*/
|
||||
public static func formatOf(container data: Data) throws -> Format {
|
||||
// TAR container should be at least 512 bytes long (when it contains only one header).
|
||||
guard data.count >= 512 else { throw TarError.tooSmallFileIsPassed }
|
||||
|
||||
/// Object with input data which supports convenient work with bit shifts.
|
||||
var infoProvider = TarEntryInfoProvider(data)
|
||||
|
||||
var specialMagicEncountered = false
|
||||
|
||||
while let info = try infoProvider.next() {
|
||||
if info.specialEntryType == .globalExtendedHeader || info.specialEntryType == .localExtendedHeader {
|
||||
return .pax
|
||||
} else if info.specialEntryType == .longName || info.specialEntryType == .longLinkName {
|
||||
return .gnu
|
||||
} else if info.hasRecognizedMagic {
|
||||
specialMagicEncountered = true
|
||||
}
|
||||
}
|
||||
|
||||
return specialMagicEncountered ? .ustar : .prePosix
|
||||
}
|
||||
|
||||
/**
|
||||
Processes TAR container and returns an array of `TarEntry` with information and data for all entries.
|
||||
|
||||
@@ -59,52 +106,13 @@ public class TarContainer: Container {
|
||||
guard data.count >= 512 else { throw TarError.tooSmallFileIsPassed }
|
||||
|
||||
/// Object with input data which supports convenient work with bit shifts.
|
||||
let byteReader = ByteReader(data: data)
|
||||
|
||||
var infoProvider = TarEntryInfoProvider(data)
|
||||
var entries = [TarEntryInfo]()
|
||||
|
||||
var lastGlobalExtendedHeader: TarExtendedHeader?
|
||||
var lastLocalExtendedHeader: TarExtendedHeader?
|
||||
var longLinkName: String?
|
||||
var longName: String?
|
||||
|
||||
// Container ends with two zero-filled records.
|
||||
while byteReader.data[byteReader.offset..<byteReader.offset + 1024] != Data(count: 1024) {
|
||||
let info = try TarEntryInfo(byteReader, lastGlobalExtendedHeader, lastLocalExtendedHeader,
|
||||
longName, longLinkName)
|
||||
|
||||
if info.isGlobalExtendedHeader {
|
||||
let dataStartIndex = info.blockStartIndex + 512
|
||||
let dataEndIndex = dataStartIndex + info.size!
|
||||
|
||||
lastGlobalExtendedHeader = try TarExtendedHeader(data[dataStartIndex..<dataEndIndex])
|
||||
byteReader.offset = dataEndIndex - info.size! + info.size!.roundTo512()
|
||||
} else if info.isLocalExtendedHeader {
|
||||
let dataStartIndex = info.blockStartIndex + 512
|
||||
let dataEndIndex = dataStartIndex + info.size!
|
||||
|
||||
lastLocalExtendedHeader = try TarExtendedHeader(data[dataStartIndex..<dataEndIndex])
|
||||
byteReader.offset = dataEndIndex - info.size! + info.size!.roundTo512()
|
||||
} else if info.isLongLinkName {
|
||||
let dataStartIndex = info.blockStartIndex + 512
|
||||
byteReader.offset = dataStartIndex
|
||||
|
||||
longLinkName = try byteReader.nullEndedAsciiString(cutoff: info.size!)
|
||||
byteReader.offset = dataStartIndex + info.size!.roundTo512()
|
||||
} else if info.isLongName {
|
||||
let dataStartIndex = info.blockStartIndex + 512
|
||||
byteReader.offset = dataStartIndex
|
||||
|
||||
longName = try byteReader.nullEndedAsciiString(cutoff: info.size!)
|
||||
byteReader.offset = dataStartIndex + info.size!.roundTo512()
|
||||
} else {
|
||||
// Skip file data.
|
||||
byteReader.offset = info.blockStartIndex + 512 + info.size!.roundTo512()
|
||||
entries.append(info)
|
||||
lastLocalExtendedHeader = nil
|
||||
longName = nil
|
||||
longLinkName = nil
|
||||
}
|
||||
while let info = try infoProvider.next() {
|
||||
guard info.specialEntryType == nil
|
||||
else { continue }
|
||||
entries.append(info)
|
||||
}
|
||||
|
||||
return entries
|
||||
|
||||
@@ -9,6 +9,13 @@ import BitByteData
|
||||
/// Provides access to information about an entry from the TAR container.
|
||||
public struct TarEntryInfo: ContainerEntryInfo {
|
||||
|
||||
enum SpecialEntryType: UInt8 {
|
||||
case longName = 76
|
||||
case longLinkName = 75
|
||||
case globalExtendedHeader = 103
|
||||
case localExtendedHeader = 120
|
||||
}
|
||||
|
||||
// MARK: ContainerEntryInfo
|
||||
|
||||
/**
|
||||
@@ -41,6 +48,9 @@ public struct TarEntryInfo: ContainerEntryInfo {
|
||||
|
||||
// MARK: TAR specific
|
||||
|
||||
/// Entry's compression method. Always `.copy` for entries of TAR containers.
|
||||
public let compressionMethod = CompressionMethod.copy
|
||||
|
||||
/// ID of entry's owner.
|
||||
public let ownerID: Int?
|
||||
|
||||
@@ -80,10 +90,8 @@ public struct TarEntryInfo: ContainerEntryInfo {
|
||||
/// All unknown records from global and local PAX extended headers. `nil`, if there were no headers.
|
||||
public let unknownExtendedHeaderRecords: [String: String]?
|
||||
|
||||
let isGlobalExtendedHeader: Bool
|
||||
let isLocalExtendedHeader: Bool
|
||||
let isLongLinkName: Bool
|
||||
let isLongName: Bool
|
||||
let specialEntryType: SpecialEntryType?
|
||||
let hasRecognizedMagic: Bool
|
||||
|
||||
let blockStartIndex: Int
|
||||
|
||||
@@ -153,10 +161,7 @@ public struct TarEntryInfo: ContainerEntryInfo {
|
||||
|
||||
// File type
|
||||
let fileTypeIndicator = byteReader.byte()
|
||||
self.isGlobalExtendedHeader = fileTypeIndicator == 103 // "g"
|
||||
self.isLocalExtendedHeader = fileTypeIndicator == 120 // "x"
|
||||
self.isLongLinkName = fileTypeIndicator == 75 // "K"
|
||||
self.isLongName = fileTypeIndicator == 76 // "L"
|
||||
self.specialEntryType = SpecialEntryType(rawValue: fileTypeIndicator)
|
||||
self.type = ContainerEntryType(fileTypeIndicator)
|
||||
|
||||
// Linked file name
|
||||
@@ -166,10 +171,11 @@ public struct TarEntryInfo: ContainerEntryInfo {
|
||||
// They differ in `magic` field value and how other fields are padded (either SPACEs or NULLs).
|
||||
// Padding is taken care of in Data extension functions in "ByteReader+Tar.swift" file.
|
||||
// Here we deal with magic. First one is "old-GNU", second is "ustar", third is for compatiblity with strange
|
||||
// implementations of "ustar", which used SPACEs instead of NULLs.
|
||||
// implementations of "ustar", which use SPACEs instead of NULLs.
|
||||
let magic = byteReader.uint64()
|
||||
|
||||
if magic == 0x0020207261747375 || magic == 0x3030007261747375 || magic == 0x3030207261747375 {
|
||||
self.hasRecognizedMagic = true
|
||||
let uname = try byteReader.nullEndedAsciiString(cutoff: 32)
|
||||
self.ownerUserName = (local?.uname ?? global?.uname) ?? uname
|
||||
|
||||
@@ -187,6 +193,7 @@ public struct TarEntryInfo: ContainerEntryInfo {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.hasRecognizedMagic = false
|
||||
ownerUserName = local?.uname ?? global?.uname
|
||||
ownerGroupName = local?.gname ?? global?.gname
|
||||
deviceMajorNumber = nil
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
// Copyright (c) 2018 Timofey Solomko
|
||||
// Licensed under MIT License
|
||||
//
|
||||
// See LICENSE for license information
|
||||
|
||||
import Foundation
|
||||
import BitByteData
|
||||
|
||||
// While it is tempting to make Provider conform to `IteratorProtocol` and `Sequence` protocols, it is in fact
|
||||
// impossible to do so, since `TarEntryInfo.init(...)` is throwing and `IteratorProtocol.next()` cannot be throwing.
|
||||
struct TarEntryInfoProvider {
|
||||
|
||||
private let byteReader: ByteReader
|
||||
private var lastGlobalExtendedHeader: TarExtendedHeader?
|
||||
private var lastLocalExtendedHeader: TarExtendedHeader?
|
||||
private var longLinkName: String?
|
||||
private var longName: String?
|
||||
|
||||
init(_ data: Data) {
|
||||
self.byteReader = ByteReader(data: data)
|
||||
}
|
||||
|
||||
mutating func next() throws -> TarEntryInfo? {
|
||||
guard byteReader.bytesLeft >= 1024,
|
||||
byteReader.data[byteReader.offset..<byteReader.offset + 1024] != Data(count: 1024)
|
||||
else { return nil }
|
||||
|
||||
let info = try TarEntryInfo(byteReader, lastGlobalExtendedHeader, lastLocalExtendedHeader,
|
||||
longName, longLinkName)
|
||||
let dataStartIndex = info.blockStartIndex + 512
|
||||
|
||||
if let specialEntryType = info.specialEntryType {
|
||||
switch specialEntryType {
|
||||
case .globalExtendedHeader:
|
||||
let dataEndIndex = dataStartIndex + info.size!
|
||||
lastGlobalExtendedHeader = try TarExtendedHeader(byteReader.data[dataStartIndex..<dataEndIndex])
|
||||
case .localExtendedHeader:
|
||||
let dataEndIndex = dataStartIndex + info.size!
|
||||
lastLocalExtendedHeader = try TarExtendedHeader(byteReader.data[dataStartIndex..<dataEndIndex])
|
||||
case .longLinkName:
|
||||
byteReader.offset = dataStartIndex
|
||||
longLinkName = try byteReader.nullEndedAsciiString(cutoff: info.size!)
|
||||
case .longName:
|
||||
byteReader.offset = dataStartIndex
|
||||
longName = try byteReader.nullEndedAsciiString(cutoff: info.size!)
|
||||
}
|
||||
byteReader.offset = dataStartIndex + info.size!.roundTo512()
|
||||
} else {
|
||||
// Skip file data.
|
||||
byteReader.offset = dataStartIndex + info.size!.roundTo512()
|
||||
lastLocalExtendedHeader = nil
|
||||
longName = nil
|
||||
longLinkName = nil
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,8 +27,8 @@ struct TarExtendedHeader {
|
||||
var charset: String?
|
||||
var comment: String?
|
||||
|
||||
init?(_ data: Data?) throws {
|
||||
guard let data = data, let headerString = String(data: data, encoding: .utf8)
|
||||
init?(_ data: Data) throws {
|
||||
guard let headerString = String(data: data, encoding: .utf8)
|
||||
else { return nil }
|
||||
|
||||
var entries = [String: String]()
|
||||
|
||||
@@ -160,8 +160,8 @@ public class XZArchive: Archive {
|
||||
_ byteReader: ByteReader) throws {
|
||||
let footerCRC = byteReader.uint32()
|
||||
/// Indicates the size of Index field. Should match its real size.
|
||||
let backwardSize = (byteReader.uint32().toInt() + 1) * 4
|
||||
let streamFooterFlags = byteReader.uint16().toInt()
|
||||
let backwardSize = (byteReader.int(fromBytes: 4) + 1) * 4
|
||||
let streamFooterFlags = byteReader.int(fromBytes: 2)
|
||||
|
||||
byteReader.offset -= 6
|
||||
guard CheckSums.crc32(byteReader.bytes(count: 6)) == footerCRC
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
// Copyright (c) 2018 Timofey Solomko
|
||||
// Licensed under MIT License
|
||||
//
|
||||
// See LICENSE for license information
|
||||
|
||||
import BitByteData
|
||||
|
||||
struct ExtendedTimestampExtraField: ZipExtraField {
|
||||
|
||||
static let id: UInt16 = 0x5455
|
||||
|
||||
let size: Int
|
||||
let location: ZipExtraFieldLocation
|
||||
|
||||
var atime: UInt32?
|
||||
var ctime: UInt32?
|
||||
var mtime: UInt32?
|
||||
|
||||
init(_ byteReader: ByteReader, _ size: Int, location: ZipExtraFieldLocation) {
|
||||
self.size = size
|
||||
self.location = location
|
||||
switch location {
|
||||
case .centralDirectory:
|
||||
let flags = byteReader.byte()
|
||||
if flags & 0x01 != 0 {
|
||||
self.mtime = byteReader.uint32()
|
||||
}
|
||||
case .localHeader:
|
||||
let flags = byteReader.byte()
|
||||
if flags & 0x01 != 0 {
|
||||
self.mtime = byteReader.uint32()
|
||||
}
|
||||
if flags & 0x02 != 0 {
|
||||
self.atime = byteReader.uint32()
|
||||
}
|
||||
if flags & 0x04 != 0 {
|
||||
self.ctime = byteReader.uint32()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
struct NtfsExtraField: ZipExtraField {
|
||||
|
||||
static let id: UInt16 = 0x000A
|
||||
|
||||
let size: Int
|
||||
let location: ZipExtraFieldLocation
|
||||
|
||||
let atime: UInt64
|
||||
let ctime: UInt64
|
||||
let mtime: UInt64
|
||||
|
||||
init?(_ byteReader: ByteReader, _ size: Int, location: ZipExtraFieldLocation) {
|
||||
self.size = size
|
||||
self.location = location
|
||||
byteReader.offset += 4 // Skip reserved bytes
|
||||
let tag = byteReader.uint16() // This attribute's tag
|
||||
byteReader.offset += 2 // Skip size of this attribute
|
||||
guard tag == 0x0001
|
||||
else { return nil }
|
||||
self.mtime = byteReader.uint64()
|
||||
self.atime = byteReader.uint64()
|
||||
self.ctime = byteReader.uint64()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
struct InfoZipUnixExtraField: ZipExtraField {
|
||||
|
||||
static let id: UInt16 = 0x7855
|
||||
|
||||
let size: Int
|
||||
let location: ZipExtraFieldLocation
|
||||
|
||||
let uid: Int
|
||||
let gid: Int
|
||||
|
||||
init?(_ byteReader: ByteReader, _ size: Int, location: ZipExtraFieldLocation) {
|
||||
self.size = size
|
||||
self.location = location
|
||||
switch location {
|
||||
case .centralDirectory:
|
||||
return nil
|
||||
case .localHeader:
|
||||
self.uid = byteReader.int(fromBytes: 2)
|
||||
self.gid = byteReader.int(fromBytes: 2)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
struct InfoZipNewUnixExtraField: ZipExtraField {
|
||||
|
||||
static let id: UInt16 = 0x7875
|
||||
|
||||
let size: Int
|
||||
let location: ZipExtraFieldLocation
|
||||
|
||||
var uid: Int?
|
||||
var gid: Int?
|
||||
|
||||
init?(_ byteReader: ByteReader, _ size: Int, location: ZipExtraFieldLocation) {
|
||||
self.size = size
|
||||
self.location = location
|
||||
guard byteReader.byte() == 1 // Version must be 1
|
||||
else { return nil }
|
||||
|
||||
let uidSize = byteReader.byte().toInt()
|
||||
if uidSize > 8 {
|
||||
byteReader.offset += uidSize
|
||||
} else {
|
||||
self.uid = byteReader.int(fromBytes: uidSize)
|
||||
}
|
||||
|
||||
let gidSize = byteReader.byte().toInt()
|
||||
if gidSize > 8 {
|
||||
byteReader.offset += gidSize
|
||||
} else {
|
||||
self.gid = byteReader.int(fromBytes: gidSize)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,18 +29,17 @@ struct ZipCentralDirectoryEntry {
|
||||
private(set) var localHeaderOffset: UInt64
|
||||
|
||||
// 0x5455 extra field.
|
||||
private(set) var modificationTimestamp: UInt32?
|
||||
private(set) var extendedTimestampExtraField: ExtendedTimestampExtraField?
|
||||
|
||||
// 0x000a extra field.
|
||||
private(set) var ntfsMtime: UInt64?
|
||||
private(set) var ntfsAtime: UInt64?
|
||||
private(set) var ntfsCtime: UInt64?
|
||||
/// 0x000a extra field.
|
||||
private(set) var ntfsExtraField: NtfsExtraField?
|
||||
|
||||
// 0x7855 extra field doesn't have any information in Central Directory.
|
||||
|
||||
// 0x7875 extra field.
|
||||
private(set) var infoZipNewUid: Int?
|
||||
private(set) var infoZipNewGid: Int?
|
||||
/// 0x7875 extra field.
|
||||
private(set) var infoZipNewUnixExtraField: InfoZipNewUnixExtraField?
|
||||
|
||||
let customExtraFields: [ZipExtraField]
|
||||
|
||||
let nextEntryOffset: Int
|
||||
|
||||
@@ -62,31 +61,33 @@ struct ZipCentralDirectoryEntry {
|
||||
|
||||
self.crc32 = byteReader.uint32()
|
||||
|
||||
self.compSize = UInt64(truncatingIfNeeded: byteReader.uint32())
|
||||
self.uncompSize = UInt64(truncatingIfNeeded: byteReader.uint32())
|
||||
self.compSize = byteReader.uint64(fromBytes: 4)
|
||||
self.uncompSize = byteReader.uint64(fromBytes: 4)
|
||||
|
||||
let fileNameLength = byteReader.uint16().toInt()
|
||||
let extraFieldLength = byteReader.uint16().toInt()
|
||||
let fileCommentLength = byteReader.uint16().toInt()
|
||||
let fileNameLength = byteReader.int(fromBytes: 2)
|
||||
let extraFieldLength = byteReader.int(fromBytes: 2)
|
||||
let fileCommentLength = byteReader.int(fromBytes: 2)
|
||||
|
||||
self.diskNumberStart = UInt32(truncatingIfNeeded: byteReader.uint16())
|
||||
self.diskNumberStart = byteReader.uint32(fromBytes: 2)
|
||||
|
||||
self.internalFileAttributes = byteReader.uint16()
|
||||
self.externalFileAttributes = byteReader.uint32()
|
||||
|
||||
self.localHeaderOffset = UInt64(truncatingIfNeeded: byteReader.uint32())
|
||||
self.localHeaderOffset = byteReader.uint64(fromBytes: 4)
|
||||
|
||||
guard let fileName = byteReader.getZipStringField(fileNameLength, useUtf8)
|
||||
else { throw ZipError.wrongTextField }
|
||||
self.fileName = fileName
|
||||
|
||||
let extraFieldStart = byteReader.offset
|
||||
var customExtraFields = [ZipExtraField]()
|
||||
while byteReader.offset - extraFieldStart < extraFieldLength {
|
||||
// There are a lot of possible extra fields.
|
||||
let headerID = byteReader.uint16()
|
||||
let size = byteReader.uint16().toInt()
|
||||
let size = byteReader.int(fromBytes: 2)
|
||||
switch headerID {
|
||||
case 0x0001: // Zip64
|
||||
// Zip64 extra field is a special case, because it requires knowledge about central directory fields.
|
||||
if self.uncompSize == 0xFFFFFFFF {
|
||||
self.uncompSize = byteReader.uint64()
|
||||
}
|
||||
@@ -100,56 +101,38 @@ struct ZipCentralDirectoryEntry {
|
||||
self.diskNumberStart = byteReader.uint32()
|
||||
}
|
||||
case 0x5455: // Extended Timestamp
|
||||
let flags = byteReader.byte()
|
||||
guard flags & 0xF8 == 0
|
||||
else { break }
|
||||
if flags & 0x01 != 0 {
|
||||
self.modificationTimestamp = byteReader.uint32()
|
||||
}
|
||||
self.extendedTimestampExtraField = ExtendedTimestampExtraField(byteReader, size,
|
||||
location: .centralDirectory)
|
||||
case 0x000a: // NTFS Extra Fields
|
||||
let ntfsExtraFieldsStartIndex = byteReader.offset
|
||||
byteReader.offset += 4 // Skipping reserved bytes.
|
||||
while byteReader.offset - ntfsExtraFieldsStartIndex < size {
|
||||
let tag = byteReader.uint16()
|
||||
byteReader.offset += 2 // Skipping size of attributes for this tag.
|
||||
if tag == 0x0001 {
|
||||
self.ntfsMtime = byteReader.uint64()
|
||||
self.ntfsAtime = byteReader.uint64()
|
||||
self.ntfsCtime = byteReader.uint64()
|
||||
}
|
||||
}
|
||||
self.ntfsExtraField = NtfsExtraField(byteReader, size, location: .centralDirectory)
|
||||
case 0x7855: // Info-ZIP Unix Extra Field
|
||||
break // It doesn't contain any information in Central Directory.
|
||||
case 0x7875: // Info-ZIP New Unix Extra Field
|
||||
guard byteReader.byte() == 1 // Version must be 1.
|
||||
else { break }
|
||||
let uidSize = byteReader.byte().toInt()
|
||||
if uidSize > 8 {
|
||||
byteReader.offset += uidSize
|
||||
} else {
|
||||
var uid = 0
|
||||
for i in 0..<uidSize {
|
||||
let byte = byteReader.byte()
|
||||
uid |= byte.toInt() << (8 * i)
|
||||
}
|
||||
self.infoZipNewUid = uid
|
||||
}
|
||||
|
||||
let gidSize = byteReader.byte().toInt()
|
||||
if gidSize > 8 {
|
||||
byteReader.offset += gidSize
|
||||
} else {
|
||||
var gid = 0
|
||||
for i in 0..<gidSize {
|
||||
let byte = byteReader.byte()
|
||||
gid |= byte.toInt() << (8 * i)
|
||||
}
|
||||
self.infoZipNewGid = gid
|
||||
}
|
||||
default:
|
||||
// If there is any data for Info-ZIP Unix extra field in central directory (`size != 0`), skip it.
|
||||
// However, according to definition of this extra field it shouldn't have any data in CD.
|
||||
byteReader.offset += size
|
||||
case 0x7875: // Info-ZIP New Unix Extra Field
|
||||
self.infoZipNewUnixExtraField = InfoZipNewUnixExtraField(byteReader, size, location: .centralDirectory)
|
||||
default:
|
||||
let customFieldOffset = byteReader.offset
|
||||
if let customExtraFieldType = ZipContainer.customExtraFields[headerID],
|
||||
customExtraFieldType.id == headerID,
|
||||
let customExtraField = customExtraFieldType.init(byteReader, size, location: .centralDirectory),
|
||||
customExtraField.id == headerID {
|
||||
precondition(customExtraField.location == .centralDirectory,
|
||||
"Custom field in Central Directory with ID=\(headerID) of type=\(customExtraFieldType)"
|
||||
+ " changed location.")
|
||||
precondition(customExtraField.size == size,
|
||||
"Custom field in Central Directory with ID=\(headerID) of type=\(customExtraFieldType)"
|
||||
+ " changed size.")
|
||||
guard byteReader.offset == customFieldOffset + size
|
||||
else { fatalError("Custom field in Central Directory with ID=\(headerID) of" +
|
||||
"type=\(customExtraFieldType) failed to read exactly \(size) bytes.") }
|
||||
customExtraFields.append(customExtraField)
|
||||
} else {
|
||||
byteReader.offset = customFieldOffset + size
|
||||
}
|
||||
}
|
||||
}
|
||||
self.customExtraFields = customExtraFields
|
||||
|
||||
guard let fileComment = byteReader.getZipStringField(fileCommentLength, useUtf8)
|
||||
else { throw ZipError.wrongTextField }
|
||||
|
||||
@@ -9,6 +9,21 @@ import BitByteData
|
||||
/// Provides functions for work with ZIP containers.
|
||||
public class ZipContainer: Container {
|
||||
|
||||
/**
|
||||
Contains user-defined extra fields. When either `ZipContainer.info(container:)` or `ZipContainer.open(container:)`
|
||||
function encounters non-standard extra field, it uses this dictionary and tries to find a corresponding
|
||||
user-defined extra field. If an approriate custom extra field is found and successfully processed, then the result
|
||||
is stored in `ZipEntryInfo.customExtraFields`.
|
||||
|
||||
To enable support of custom extra field one must add a new entry to this dictionary. The value of this entry must
|
||||
be a user-defined type which conforms to `ZipExtraField` protocol. The key must be equal to the ID of user-defined
|
||||
extra field and type's `id` property.
|
||||
|
||||
- Warning: Modifying this dictionary while either `info(container:)` or `open(container:)` function is being
|
||||
executed may cause undefined behavior.
|
||||
*/
|
||||
public static var customExtraFields = [UInt16: ZipExtraField.Type]()
|
||||
|
||||
/**
|
||||
Processes ZIP container and returns an array of `ZipEntry` with information and data for all entries.
|
||||
|
||||
@@ -100,8 +115,8 @@ public class ZipContainer: Container {
|
||||
compSize = byteReader.uint64()
|
||||
uncompSize = byteReader.uint64()
|
||||
} else {
|
||||
compSize = UInt64(truncatingIfNeeded: byteReader.uint32())
|
||||
uncompSize = UInt64(truncatingIfNeeded: byteReader.uint32())
|
||||
compSize = byteReader.uint64(fromBytes: 4)
|
||||
uncompSize = byteReader.uint64(fromBytes: 4)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +166,7 @@ public class ZipContainer: Container {
|
||||
// But first, we should check for "Archive extra data record" and skip it if present.
|
||||
byteReader.offset = endOfCD.cdOffset.toInt()
|
||||
if byteReader.uint32() == 0x08064b50 {
|
||||
byteReader.offset += byteReader.uint32().toInt()
|
||||
byteReader.offset += byteReader.int(fromBytes: 4)
|
||||
} else {
|
||||
byteReader.offset -= 4
|
||||
}
|
||||
|
||||
@@ -21,26 +21,26 @@ struct ZipEndOfCentralDirectory {
|
||||
/// Indicates if Zip64 records should be present.
|
||||
var zip64RecordExists = false
|
||||
|
||||
self.currentDiskNumber = UInt32(truncatingIfNeeded: byteReader.uint16())
|
||||
self.cdDiskNumber = UInt32(truncatingIfNeeded: byteReader.uint16())
|
||||
self.currentDiskNumber = byteReader.uint32(fromBytes: 2)
|
||||
self.cdDiskNumber = byteReader.uint32(fromBytes: 2)
|
||||
guard self.currentDiskNumber == self.cdDiskNumber
|
||||
else { throw ZipError.multiVolumesNotSupported }
|
||||
|
||||
/// Number of CD entries on the current disk.
|
||||
var cdEntriesCurrentDisk = UInt64(truncatingIfNeeded: byteReader.uint16())
|
||||
var cdEntriesCurrentDisk = byteReader.uint64(fromBytes: 2)
|
||||
/// Total number of CD entries.
|
||||
self.cdEntries = UInt64(truncatingIfNeeded: byteReader.uint16())
|
||||
self.cdEntries = byteReader.uint64(fromBytes: 2)
|
||||
guard cdEntries == cdEntriesCurrentDisk
|
||||
else { throw ZipError.multiVolumesNotSupported }
|
||||
|
||||
/// Size of Central Directory.
|
||||
self.cdSize = UInt64(truncatingIfNeeded: byteReader.uint32())
|
||||
self.cdSize = byteReader.uint64(fromBytes: 4)
|
||||
/// Offset to the start of Central Directory.
|
||||
self.cdOffset = UInt64(truncatingIfNeeded: byteReader.uint32())
|
||||
self.cdOffset = byteReader.uint64(fromBytes: 4)
|
||||
|
||||
// There is also a .ZIP file comment, but we don't need it.
|
||||
// Here's how it can be processed:
|
||||
// let zipCommentLength = byteReader.uint16().toInt()
|
||||
// let zipCommentLength = byteReader.int(fromBytes: 2)
|
||||
// let zipComment = String(data: Data(bytes: byteReader.bytes(count: zipCommentLength)),
|
||||
// encoding: .utf8)
|
||||
|
||||
@@ -65,13 +65,13 @@ struct ZipEndOfCentralDirectory {
|
||||
guard self.currentDiskNumber == zip64CDStartDisk
|
||||
else { throw ZipError.multiVolumesNotSupported }
|
||||
|
||||
let zip64CDEndOffset = byteReader.uint64()
|
||||
let zip64CDEndOffset = byteReader.int(fromBytes: 8)
|
||||
let totalDisks = byteReader.uint32()
|
||||
guard totalDisks == 1
|
||||
else { throw ZipError.multiVolumesNotSupported }
|
||||
|
||||
// Now we need to move to Zip64 End of CD.
|
||||
byteReader.offset = zip64CDEndOffset.toInt()
|
||||
byteReader.offset = zip64CDEndOffset
|
||||
|
||||
// Check signature.
|
||||
guard byteReader.uint32() == 0x06064b50
|
||||
|
||||
@@ -92,6 +92,13 @@ public struct ZipEntryInfo: ContainerEntryInfo {
|
||||
*/
|
||||
public let groupID: Int?
|
||||
|
||||
/**
|
||||
Entry's custom extra fields from both Central Directory and Local Header.
|
||||
|
||||
- Note: No particular order of extra fields is guaranteed.
|
||||
*/
|
||||
public let customExtraFields: [ZipExtraField]
|
||||
|
||||
let cdEntry: ZipCentralDirectoryEntry
|
||||
let localHeader: ZipLocalHeader
|
||||
|
||||
@@ -111,12 +118,12 @@ public struct ZipEntryInfo: ContainerEntryInfo {
|
||||
self.name = cdEntry.fileName
|
||||
|
||||
// Set Modification Time.
|
||||
if let mtimestamp = cdEntry.modificationTimestamp {
|
||||
if let mtime = cdEntry.extendedTimestampExtraField?.mtime {
|
||||
// Extended Timestamp extra field.
|
||||
self.modificationTime = Date(timeIntervalSince1970: TimeInterval(mtimestamp))
|
||||
} else if let mtime = Date(cdEntry.ntfsMtime) {
|
||||
self.modificationTime = Date(timeIntervalSince1970: TimeInterval(mtime))
|
||||
} else if let mtime = cdEntry.ntfsExtraField?.mtime {
|
||||
// NTFS extra field.
|
||||
self.modificationTime = mtime
|
||||
self.modificationTime = Date(mtime)
|
||||
} else {
|
||||
// Native ZIP modification time.
|
||||
let dosDate = cdEntry.lastModFileDate.toInt()
|
||||
@@ -137,29 +144,29 @@ public struct ZipEntryInfo: ContainerEntryInfo {
|
||||
}
|
||||
|
||||
// Set Creation Time.
|
||||
if let ctimestamp = localHeader.creationTimestamp {
|
||||
if let ctime = localHeader.extendedTimestampExtraField?.ctime {
|
||||
// Extended Timestamp extra field.
|
||||
self.creationTime = Date(timeIntervalSince1970: TimeInterval(ctimestamp))
|
||||
} else if let ctime = Date(cdEntry.ntfsCtime) {
|
||||
self.creationTime = Date(timeIntervalSince1970: TimeInterval(ctime))
|
||||
} else if let ctime = cdEntry.ntfsExtraField?.ctime {
|
||||
// NTFS extra field.
|
||||
self.creationTime = ctime
|
||||
self.creationTime = Date(ctime)
|
||||
} else {
|
||||
self.creationTime = nil
|
||||
}
|
||||
|
||||
// Set Creation Time.
|
||||
if let atimestamp = localHeader.accessTimestamp {
|
||||
if let atime = localHeader.extendedTimestampExtraField?.atime {
|
||||
// Extended Timestamp extra field.
|
||||
self.accessTime = Date(timeIntervalSince1970: TimeInterval(atimestamp))
|
||||
} else if let atime = Date(cdEntry.ntfsAtime) {
|
||||
self.accessTime = Date(timeIntervalSince1970: TimeInterval(atime))
|
||||
} else if let atime = cdEntry.ntfsExtraField?.atime {
|
||||
// NTFS extra field.
|
||||
self.accessTime = atime
|
||||
self.accessTime = Date(atime)
|
||||
} else {
|
||||
self.accessTime = nil
|
||||
}
|
||||
|
||||
// Size
|
||||
self.size = Int(cdEntry.uncompSize)
|
||||
self.size = cdEntry.uncompSize.toInt()
|
||||
|
||||
// External file attributes.
|
||||
self.externalFileAttributes = cdEntry.externalFileAttributes
|
||||
@@ -194,10 +201,15 @@ public struct ZipEntryInfo: ContainerEntryInfo {
|
||||
self.compressionMethod = CompressionMethod(localHeader.compressionMethod)
|
||||
|
||||
// Owner's ID.
|
||||
self.ownerID = localHeader.infoZipNewUid ?? localHeader.infoZipUid?.toInt()
|
||||
self.ownerID = localHeader.infoZipNewUnixExtraField?.uid ?? localHeader.infoZipUnixExtraField?.uid
|
||||
|
||||
// Owner's group ID.
|
||||
self.groupID = localHeader.infoZipNewGid ?? localHeader.infoZipGid?.toInt()
|
||||
self.groupID = localHeader.infoZipNewUnixExtraField?.gid ?? localHeader.infoZipUnixExtraField?.gid
|
||||
|
||||
// Custom extra fields.
|
||||
var customExtraFields = cdEntry.customExtraFields
|
||||
customExtraFields.append(contentsOf: localHeader.customExtraFields)
|
||||
self.customExtraFields = customExtraFields
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
// Copyright (c) 2018 Timofey Solomko
|
||||
// Licensed under MIT License
|
||||
//
|
||||
// See LICENSE for license information
|
||||
|
||||
import BitByteData
|
||||
|
||||
/// A type that represents an extra field from ZIP container.
|
||||
public protocol ZipExtraField {
|
||||
|
||||
/**
|
||||
ID of extra field. Must be equal to the key of extra field in `ZipContainer.customExtraFields` dictionary and
|
||||
instance `id` property
|
||||
*/
|
||||
static var id: UInt16 { get }
|
||||
|
||||
/// Location of extra field. Must be equal to the value of `location` argument of `init?(_:_:location:)`.
|
||||
var location: ZipExtraFieldLocation { get }
|
||||
|
||||
/// Size of extra field's data. Must be equal to the value of the second argument of `init?(_:_:location:)`.
|
||||
var size: Int { get }
|
||||
|
||||
/**
|
||||
Creates an extra field instance reading `size` amount of data from `byteReader`.
|
||||
|
||||
It is guaranteed that the offset of `byteReader` is equal to the position right after extra field header ID and
|
||||
length of extra field data. It is also guaranteed that header ID matches conforming type's static `id` property.
|
||||
|
||||
Following conditions are checked after execution of this initializer. Failure to satisfy them in conforming type
|
||||
will result in runtime error.
|
||||
|
||||
- Postcondition: `location` property of a created instance must be equal to the `location` argument.
|
||||
- Postcondition: `size` property of a created instance must be equal to the second argument.
|
||||
- Postcondition: exactly `size` amount of bytes must be read by initializer from `byteReader`.
|
||||
*/
|
||||
init?(_ byteReader: ByteReader, _ size: Int, location: ZipExtraFieldLocation)
|
||||
|
||||
}
|
||||
|
||||
extension ZipExtraField {
|
||||
|
||||
/**
|
||||
ID of extra field. Must be equal to the key of extra field in `ZipContainer.customExtraFields` dictionary and
|
||||
static `id` property
|
||||
*/
|
||||
public var id: UInt16 {
|
||||
return Self.id
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Location of ZIP extra field inside a container.
|
||||
public enum ZipExtraFieldLocation {
|
||||
/// ZIP extra field is located in container's Central Directory.
|
||||
case centralDirectory
|
||||
/// ZIP extra field is located in one of container's Local Headers.
|
||||
case localHeader
|
||||
}
|
||||
@@ -22,23 +22,19 @@ struct ZipLocalHeader {
|
||||
|
||||
let fileName: String
|
||||
|
||||
// 0x5455 extra field.
|
||||
private(set) var modificationTimestamp: UInt32?
|
||||
private(set) var accessTimestamp: UInt32?
|
||||
private(set) var creationTimestamp: UInt32?
|
||||
/// 0x5455 extra field.
|
||||
private(set) var extendedTimestampExtraField: ExtendedTimestampExtraField?
|
||||
|
||||
// 0x000a extra field.
|
||||
private(set) var ntfsMtime: UInt64?
|
||||
private(set) var ntfsAtime: UInt64?
|
||||
private(set) var ntfsCtime: UInt64?
|
||||
/// 0x000a extra field.
|
||||
private(set) var ntfsExtraField: NtfsExtraField?
|
||||
|
||||
// 0x7855 extra field.
|
||||
private(set) var infoZipUid: UInt16?
|
||||
private(set) var infoZipGid: UInt16?
|
||||
/// 0x7855 extra field.
|
||||
private(set) var infoZipUnixExtraField: InfoZipUnixExtraField?
|
||||
|
||||
// 0x7875 extra field.
|
||||
private(set) var infoZipNewUid: Int?
|
||||
private(set) var infoZipNewGid: Int?
|
||||
/// 0x7875 extra field.
|
||||
private(set) var infoZipNewUnixExtraField: InfoZipNewUnixExtraField?
|
||||
|
||||
let customExtraFields: [ZipExtraField]
|
||||
|
||||
let dataOffset: Int
|
||||
|
||||
@@ -59,86 +55,60 @@ struct ZipLocalHeader {
|
||||
|
||||
self.crc32 = byteReader.uint32()
|
||||
|
||||
self.compSize = UInt64(truncatingIfNeeded: byteReader.uint32())
|
||||
self.uncompSize = UInt64(truncatingIfNeeded: byteReader.uint32())
|
||||
self.compSize = byteReader.uint64(fromBytes: 4)
|
||||
self.uncompSize = byteReader.uint64(fromBytes: 4)
|
||||
|
||||
let fileNameLength = byteReader.uint16().toInt()
|
||||
let extraFieldLength = byteReader.uint16().toInt()
|
||||
let fileNameLength = byteReader.int(fromBytes: 2)
|
||||
let extraFieldLength = byteReader.int(fromBytes: 2)
|
||||
|
||||
guard let fileName = byteReader.getZipStringField(fileNameLength, useUtf8)
|
||||
else { throw ZipError.wrongTextField }
|
||||
self.fileName = fileName
|
||||
|
||||
let extraFieldStart = byteReader.offset
|
||||
var customExtraFields = [ZipExtraField]()
|
||||
while byteReader.offset - extraFieldStart < extraFieldLength {
|
||||
// There are a lot of possible extra fields.
|
||||
let headerID = byteReader.uint16()
|
||||
let size = byteReader.uint16().toInt()
|
||||
let size = byteReader.int(fromBytes: 2)
|
||||
switch headerID {
|
||||
case 0x0001: // Zip64
|
||||
// Zip64 extra field is a special case, because it requires knowledge about local header fields,
|
||||
// in particular, uncompressed and compressed sizes.
|
||||
// In local header both uncompressed size and compressed size fields are required.
|
||||
self.uncompSize = byteReader.uint64()
|
||||
self.compSize = byteReader.uint64()
|
||||
|
||||
self.zip64FieldsArePresent = true
|
||||
case 0x5455: // Extended Timestamp
|
||||
let flags = byteReader.byte()
|
||||
guard flags & 0xF8 == 0
|
||||
else { break }
|
||||
if flags & 0x01 != 0 {
|
||||
self.modificationTimestamp = byteReader.uint32()
|
||||
}
|
||||
if flags & 0x02 != 0 {
|
||||
self.accessTimestamp = byteReader.uint32()
|
||||
}
|
||||
if flags & 0x04 != 0 {
|
||||
self.creationTimestamp = byteReader.uint32()
|
||||
}
|
||||
self.extendedTimestampExtraField = ExtendedTimestampExtraField(byteReader, size, location: .localHeader)
|
||||
case 0x000a: // NTFS Extra Fields
|
||||
let ntfsExtraFieldsStartIndex = byteReader.offset
|
||||
byteReader.offset += 4 // Skipping reserved bytes.
|
||||
while byteReader.offset - ntfsExtraFieldsStartIndex < size {
|
||||
let tag = byteReader.uint16()
|
||||
byteReader.offset += 2 // Skipping size of attributes for this tag.
|
||||
if tag == 0x0001 {
|
||||
self.ntfsMtime = byteReader.uint64()
|
||||
self.ntfsAtime = byteReader.uint64()
|
||||
self.ntfsCtime = byteReader.uint64()
|
||||
}
|
||||
}
|
||||
self.ntfsExtraField = NtfsExtraField(byteReader, size, location: .localHeader)
|
||||
case 0x7855: // Info-ZIP Unix Extra Field
|
||||
self.infoZipUid = byteReader.uint16()
|
||||
self.infoZipGid = byteReader.uint16()
|
||||
self.infoZipUnixExtraField = InfoZipUnixExtraField(byteReader, size, location: .localHeader)
|
||||
case 0x7875: // Info-ZIP New Unix Extra Field
|
||||
guard byteReader.byte() == 1 // Version must be 1.
|
||||
else { break }
|
||||
let uidSize = byteReader.byte().toInt()
|
||||
if uidSize > 8 {
|
||||
byteReader.offset += uidSize
|
||||
} else {
|
||||
var uid = 0
|
||||
for i in 0..<uidSize {
|
||||
let byte = byteReader.byte()
|
||||
uid |= byte.toInt() << (8 * i)
|
||||
}
|
||||
self.infoZipNewUid = uid
|
||||
}
|
||||
|
||||
let gidSize = byteReader.byte().toInt()
|
||||
if gidSize > 8 {
|
||||
byteReader.offset += gidSize
|
||||
} else {
|
||||
var gid = 0
|
||||
for i in 0..<gidSize {
|
||||
let byte = byteReader.byte()
|
||||
gid |= byte.toInt() << (8 * i)
|
||||
}
|
||||
self.infoZipNewGid = gid
|
||||
}
|
||||
self.infoZipNewUnixExtraField = InfoZipNewUnixExtraField(byteReader, size, location: .localHeader)
|
||||
default:
|
||||
byteReader.offset += size
|
||||
let customFieldOffset = byteReader.offset
|
||||
if let customExtraFieldType = ZipContainer.customExtraFields[headerID],
|
||||
customExtraFieldType.id == headerID,
|
||||
let customExtraField = customExtraFieldType.init(byteReader, size, location: .localHeader),
|
||||
customExtraField.id == headerID {
|
||||
precondition(customExtraField.location == .localHeader,
|
||||
"Custom field in Local Header with ID=\(headerID) of type=\(customExtraFieldType)"
|
||||
+ " changed location.")
|
||||
precondition(customExtraField.size == size,
|
||||
"Custom field in Local Header with ID=\(headerID) of type=\(customExtraFieldType)"
|
||||
+ " changed size.")
|
||||
guard byteReader.offset == customFieldOffset + size
|
||||
else { fatalError("Custom field in Local Header with ID=\(headerID) of" +
|
||||
"type=\(customExtraFieldType) failed to read exactly \(size) bytes.") }
|
||||
customExtraFields.append(customExtraField)
|
||||
} else {
|
||||
byteReader.offset = customFieldOffset + size
|
||||
}
|
||||
}
|
||||
}
|
||||
self.customExtraFields = customExtraFields
|
||||
|
||||
self.dataOffset = byteReader.offset
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ class CompBz2: Command {
|
||||
var maxTime = Double(Int.min)
|
||||
var minTime = Double(Int.max)
|
||||
|
||||
for i in 1...6 {
|
||||
_ = BZip2.compress(data: fileData)
|
||||
for i in 1...10 {
|
||||
print("Iteration \(i): ", terminator: "")
|
||||
let startTime = CFAbsoluteTimeGetCurrent()
|
||||
_ = BZip2.compress(data: fileData)
|
||||
@@ -47,7 +48,7 @@ class CompBz2: Command {
|
||||
minTime = timeElapsed
|
||||
}
|
||||
}
|
||||
print(String(format: "\nAverage time: %.3f \u{B1} %.3f", totalTime / 6, (maxTime - minTime) / 2))
|
||||
print(String(format: "\nAverage time: %.3f \u{B1} %.3f", totalTime / 10, (maxTime - minTime) / 2))
|
||||
print("-----------------------------------")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ class CompDeflate: Command {
|
||||
var maxTime = Double(Int.min)
|
||||
var minTime = Double(Int.max)
|
||||
|
||||
for i in 1...6 {
|
||||
_ = Deflate.compress(data: fileData)
|
||||
for i in 1...10 {
|
||||
print("Iteration \(i): ", terminator: "")
|
||||
let startTime = CFAbsoluteTimeGetCurrent()
|
||||
_ = Deflate.compress(data: fileData)
|
||||
@@ -47,7 +48,7 @@ class CompDeflate: Command {
|
||||
minTime = timeElapsed
|
||||
}
|
||||
}
|
||||
print(String(format: "\nAverage time: %.3f \u{B1} %.3f", totalTime / 6, (maxTime - minTime) / 2))
|
||||
print(String(format: "\nAverage time: %.3f \u{B1} %.3f", totalTime / 10, (maxTime - minTime) / 2))
|
||||
print("----------------------------------")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ class Info7z: Command {
|
||||
var maxTime = Double(Int.min)
|
||||
var minTime = Double(Int.max)
|
||||
|
||||
for i in 1...6 {
|
||||
_ = try SevenZipContainer.info(container: fileData)
|
||||
for i in 1...10 {
|
||||
print("Iteration \(i): ", terminator: "")
|
||||
let startTime = CFAbsoluteTimeGetCurrent()
|
||||
_ = try SevenZipContainer.info(container: fileData)
|
||||
@@ -47,7 +48,7 @@ class Info7z: Command {
|
||||
minTime = timeElapsed
|
||||
}
|
||||
}
|
||||
print(String(format: "\nAverage time: %.3f \u{B1} %.3f", totalTime / 6, (maxTime - minTime) / 2))
|
||||
print(String(format: "\nAverage time: %.3f \u{B1} %.3f", totalTime / 10, (maxTime - minTime) / 2))
|
||||
print("---------------------------------------")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ class InfoTar: Command {
|
||||
var maxTime = Double(Int.min)
|
||||
var minTime = Double(Int.max)
|
||||
|
||||
for i in 1...6 {
|
||||
_ = try TarContainer.info(container: fileData)
|
||||
for i in 1...10 {
|
||||
print("Iteration \(i): ", terminator: "")
|
||||
let startTime = CFAbsoluteTimeGetCurrent()
|
||||
_ = try TarContainer.info(container: fileData)
|
||||
@@ -47,7 +48,7 @@ class InfoTar: Command {
|
||||
minTime = timeElapsed
|
||||
}
|
||||
}
|
||||
print(String(format: "\nAverage time: %.3f \u{B1} %.3f", totalTime / 6, (maxTime - minTime) / 2))
|
||||
print(String(format: "\nAverage time: %.3f \u{B1} %.3f", totalTime / 10, (maxTime - minTime) / 2))
|
||||
print("-------------------------------------")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ class InfoZip: Command {
|
||||
var maxTime = Double(Int.min)
|
||||
var minTime = Double(Int.max)
|
||||
|
||||
for i in 1...6 {
|
||||
_ = try ZipContainer.info(container: fileData)
|
||||
for i in 1...10 {
|
||||
print("Iteration \(i): ", terminator: "")
|
||||
let startTime = CFAbsoluteTimeGetCurrent()
|
||||
_ = try ZipContainer.info(container: fileData)
|
||||
@@ -47,7 +48,7 @@ class InfoZip: Command {
|
||||
minTime = timeElapsed
|
||||
}
|
||||
}
|
||||
print(String(format: "\nAverage time: %.3f \u{B1} %.3f", totalTime / 6, (maxTime - minTime) / 2))
|
||||
print(String(format: "\nAverage time: %.3f \u{B1} %.3f", totalTime / 10, (maxTime - minTime) / 2))
|
||||
print("-------------------------------------")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ class UnBz2: Command {
|
||||
var maxTime = Double(Int.min)
|
||||
var minTime = Double(Int.max)
|
||||
|
||||
for i in 1...6 {
|
||||
_ = try BZip2.decompress(data: fileData)
|
||||
for i in 1...10 {
|
||||
print("Iteration \(i): ", terminator: "")
|
||||
let startTime = CFAbsoluteTimeGetCurrent()
|
||||
_ = try BZip2.decompress(data: fileData)
|
||||
@@ -47,7 +48,7 @@ class UnBz2: Command {
|
||||
minTime = timeElapsed
|
||||
}
|
||||
}
|
||||
print(String(format: "\nAverage time: %.3f \u{B1} %.3f", totalTime / 6, (maxTime - minTime) / 2))
|
||||
print(String(format: "\nAverage time: %.3f \u{B1} %.3f", totalTime / 10, (maxTime - minTime) / 2))
|
||||
print("-----------------------------------")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ class UnGzip: Command {
|
||||
var maxTime = Double(Int.min)
|
||||
var minTime = Double(Int.max)
|
||||
|
||||
for i in 1...6 {
|
||||
_ = try GzipArchive.unarchive(archive: fileData)
|
||||
for i in 1...10 {
|
||||
print("Iteration \(i): ", terminator: "")
|
||||
let startTime = CFAbsoluteTimeGetCurrent()
|
||||
_ = try GzipArchive.unarchive(archive: fileData)
|
||||
@@ -47,7 +48,7 @@ class UnGzip: Command {
|
||||
minTime = timeElapsed
|
||||
}
|
||||
}
|
||||
print(String(format: "\nAverage time: %.3f \u{B1} %.3f", totalTime / 6, (maxTime - minTime) / 2))
|
||||
print(String(format: "\nAverage time: %.3f \u{B1} %.3f", totalTime / 10, (maxTime - minTime) / 2))
|
||||
print("----------------------------------")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ class UnXz: Command {
|
||||
var maxTime = Double(Int.min)
|
||||
var minTime = Double(Int.max)
|
||||
|
||||
for i in 1...6 {
|
||||
_ = try XZArchive.unarchive(archive: fileData)
|
||||
for i in 1...10 {
|
||||
print("Iteration \(i): ", terminator: "")
|
||||
let startTime = CFAbsoluteTimeGetCurrent()
|
||||
_ = try XZArchive.unarchive(archive: fileData)
|
||||
@@ -47,7 +48,7 @@ class UnXz: Command {
|
||||
minTime = timeElapsed
|
||||
}
|
||||
}
|
||||
print(String(format: "\nAverage time: %.3f \u{B1} %.3f", totalTime / 6, (maxTime - minTime) / 2))
|
||||
print(String(format: "\nAverage time: %.3f \u{B1} %.3f", totalTime / 10, (maxTime - minTime) / 2))
|
||||
print("--------------------------------")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ import SwiftCLI
|
||||
import SWCompression
|
||||
|
||||
/// This extension allows to use `BlockSize` as a `Key` option.
|
||||
extension BZip2.BlockSize: Keyable {
|
||||
extension BZip2.BlockSize: ConvertibleFromString {
|
||||
|
||||
public static func val(from: String) -> BZip2.BlockSize? {
|
||||
public static func convert(from: String) -> BZip2.BlockSize? {
|
||||
guard let num = Int(from)
|
||||
else { return nil }
|
||||
return BZip2.BlockSize(rawValue: num)
|
||||
|
||||
@@ -18,12 +18,13 @@ class TarCommand: Command {
|
||||
|
||||
let info = Flag("-i", "--info", description: "Print list of entries in container and their attributes")
|
||||
let extract = Key<String>("-e", "--extract", description: "Extract container into specified directory")
|
||||
let format = Flag("-f", "--format", description: "Prints \"format\" of the container")
|
||||
|
||||
let verbose = Flag("--verbose", description: "Print the list of extracted files and directories.")
|
||||
|
||||
var optionGroups: [OptionGroup] {
|
||||
let compressions = OptionGroup(options: [gz, bz2, xz], restriction: .atMostOne)
|
||||
let actions = OptionGroup(options: [info, extract], restriction: .exactlyOne)
|
||||
let actions = OptionGroup(options: [info, extract, format], restriction: .exactlyOne)
|
||||
return [compressions, actions]
|
||||
}
|
||||
|
||||
@@ -52,6 +53,19 @@ class TarCommand: Command {
|
||||
|
||||
let entries = try TarContainer.open(container: fileData)
|
||||
try swcomp.write(entries, outputPath, verbose.value)
|
||||
} else if format.value {
|
||||
let format = try TarContainer.formatOf(container: fileData)
|
||||
switch format {
|
||||
case .prePosix:
|
||||
print("TAR format: pre-POSIX")
|
||||
case .ustar:
|
||||
print("TAR format: POSIX aka \"ustar\"")
|
||||
case .gnu:
|
||||
print("TAR format: POSIX with GNU extensions")
|
||||
case .pax:
|
||||
print("TAR format: PAX")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import Foundation
|
||||
import SWCompression
|
||||
import SwiftCLI
|
||||
|
||||
let cli = CLI(name: "swcomp", version: "4.2.2",
|
||||
let cli = CLI(name: "swcomp", version: "4.3.0",
|
||||
description: """
|
||||
swcomp - small command-line client for SWCompression framework.
|
||||
Serves as an example of SWCompression usage.
|
||||
|
||||
@@ -48,7 +48,7 @@ class GzipTests: XCTestCase {
|
||||
|
||||
// Options for archiving.
|
||||
let mtimeDate = Date(timeIntervalSinceNow: 0.0)
|
||||
let mtime = Double(Int(mtimeDate.timeIntervalSince1970))
|
||||
let mtime = mtimeDate.timeIntervalSince1970.rounded(.towardZero)
|
||||
|
||||
// Test GZip archiving.
|
||||
let archiveData = try GzipArchive.archive(data: answerData, comment: "some file comment",
|
||||
|
||||
+49
-38
@@ -1,17 +1,22 @@
|
||||
# Test Results
|
||||
|
||||
In this document you can find the results of benchmarking which were run on Macbook Pro, Late 2011.
|
||||
The main purpose of these results is to track the progress from version to version.
|
||||
In this document you can find the results of benchmarking which was performed on Macbook Pro, Late 2011. The main
|
||||
purpose of these results is to track progress from version to version.
|
||||
|
||||
__Note:__ Since version 4.1.0 of SWCompression internal functionality related to reading/writing bits and bytes
|
||||
__Note:__ Since 4.1.0 version of SWCompression internal functionality related to reading/writing bits and bytes
|
||||
is published as a separate framework, [BitByteData](https://github.com/tsolomko/BitByteData).
|
||||
It is worth mentioning that overall performance depends on the speed of reading and writing,
|
||||
and thus BitByteData's version (which is specified in a separate column in the tables below)
|
||||
becomes relevant to benchmarking, since newer version can contain speed improvements.
|
||||
The overall performance heavily depends on the speed of reading and writing, and thus BitByteData's version, which is
|
||||
specified in a separate column in the tables below, becomes relevant to benchmarking, since newer versions can contain
|
||||
performance improvements.
|
||||
|
||||
__Note:__ Since 4.3.0 version of SWCompression the first (zeroth, actually) iteration is excluded from averages
|
||||
calculation since this iteration has abnormally longer execution time than any of the following iterations. This
|
||||
exclusion led not only to (artificially) improved results, but also to the increased quality of the results by reducing
|
||||
calculated uncertainty.
|
||||
|
||||
## Tests description
|
||||
|
||||
There are three different datasets for testing. When choosing them I was trying to have something,
|
||||
There are three different datasets for testing. When choosing them the intention was to have something
|
||||
that represents real life situations. For obvious reasons these test files aren't provided anywhere
|
||||
in the repository.
|
||||
|
||||
@@ -22,52 +27,58 @@ in the repository.
|
||||
All tests were run using swcomp's "benchmark" command. SWCompression (and swcomp) were compiled
|
||||
using "Release" configuration.
|
||||
|
||||
__Note:__ All results are averages over 6 iterations.
|
||||
__Note:__ All results are averages over 10 iterations (6 iterations until 4.3.0 version).
|
||||
|
||||
## BZip2 Decompress
|
||||
|
||||
|SWCompression<br>version|BitByteData<br>version|Test 1|Test 2|Test 3|
|
||||
|:---:|:---:|---|---|---|
|
||||
|4.0.0|—|6.821 ± 0.042|54.214 ± 1.398|7.255 ± 0.117|
|
||||
|4.0.1|—|6.797 ± 0.080|54.046 ± 1.070|7.177 ± 0.029|
|
||||
|4.1.0|1.0.1|4.452 ± 0.125|36.768 ± 0.382|4.880 ± 0.094|
|
||||
|SWCompression<br>version|BitByteData<br>version|Swift<br>version|Test 1|Test 2|Test 3|
|
||||
|:---:|:---:|:---:|---|---|---|
|
||||
|4.0.0|—|4.0.X|6.821 ± 0.042|54.214 ± 1.398|7.255 ± 0.117|
|
||||
|4.0.1|—|4.0.X|6.797 ± 0.080|54.046 ± 1.070|7.177 ± 0.029|
|
||||
|4.1.0|1.0.1|4.0.X|4.452 ± 0.125|36.768 ± 0.382|4.880 ± 0.094|
|
||||
|4.3.0|1.2.0|4.1.0|3.481 ± 0.038|27.187 ± 0.152|3.914 ± 0.091|
|
||||
|
||||
## XZ Unarchive (LZMA/LZMA2 Decompress)
|
||||
|
||||
|SWCompression<br>version|BitByteData<br>version|Test 1|Test 2|Test 3|
|
||||
|:---:|:---:|---|---|---|
|
||||
|4.0.0|—|error|24.663 ± 2.349|2.904 ± 0.076|
|
||||
|4.0.1|—|2.475 ± 0.067|23.507 ± 0.423|2.901 ± 0.049|
|
||||
|4.1.0|1.0.1|2.480 ± 0.091|24.126 ± 1.239|2.892 ± 0.052|
|
||||
|SWCompression<br>version|BitByteData<br>version|Swift<br>version|Test 1|Test 2|Test 3|
|
||||
|:---:|:---:|:---:|---|---|---|
|
||||
|4.0.0|—|4.0.X|error|24.663 ± 2.349|2.904 ± 0.076|
|
||||
|4.0.1|—|4.0.X|2.475 ± 0.067|23.507 ± 0.423|2.901 ± 0.049|
|
||||
|4.1.0|1.0.1|4.0.X|2.480 ± 0.091|24.126 ± 1.239|2.892 ± 0.052|
|
||||
|4.3.0|1.2.0|4.1.0|2.664 ± 0.031|26.030 ± 1.200|3.111 ± 0.053|
|
||||
|
||||
## GZip Unarchive (Deflate Decompress)
|
||||
|
||||
|SWCompression<br>version|BitByteData<br>version|Test 1|Test 2|Test 3|
|
||||
|:---:|:---:|---|---|---|
|
||||
|4.0.0|—|4.007 ± 0.196|32.043 ± 0.581|4.303 ± 0.045|
|
||||
|4.0.1|—|3.886 ± 0.100|32.390 ± 0.896|4.295 ± 0.040|
|
||||
|4.1.0|1.0.1|2.886 ± 0.571|22.134 ± 1.473|2.700 ± 0.168|
|
||||
|SWCompression<br>version|BitByteData<br>version|Swift<br>version|Test 1|Test 2|Test 3|
|
||||
|:---:|:---:|:---:|---|---|---|
|
||||
|4.0.0|—|4.0.X|4.007 ± 0.196|32.043 ± 0.581|4.303 ± 0.045|
|
||||
|4.0.1|—|4.0.X|3.886 ± 0.100|32.390 ± 0.896|4.295 ± 0.040|
|
||||
|4.1.0|1.0.1|4.0.X|2.886 ± 0.571|22.134 ± 1.473|2.700 ± 0.168|
|
||||
|4.3.0|1.2.0|4.1.0|1.622 ± 0.016|13.641 ± 0.069|1.804 ± 0.028|
|
||||
|
||||
## 7-Zip Info Function
|
||||
|
||||
|SWCompression<br>version|BitByteData<br>version|Test 1|Test 2|Test 3|
|
||||
|:---:|:---:|---|---|---|
|
||||
|4.0.0|—|0.270 ± 0.010|crash|0.601 ± 0.057|
|
||||
|4.0.1|—|0.258 ± 0.003|0.601 ± 0.010|0.473 ± 0.008|
|
||||
|4.1.0|1.0.1|0.062 ± 0.008|0.208 ± 0.010|0.122 ± 0.003|
|
||||
|SWCompression<br>version|BitByteData<br>version|Swift<br>version|Test 1|Test 2|Test 3|
|
||||
|:---:|:---:|:---:|---|---|---|
|
||||
|4.0.0|—|4.0.X|0.270 ± 0.010|crash|0.601 ± 0.057|
|
||||
|4.0.1|—|4.0.X|0.258 ± 0.003|0.601 ± 0.010|0.473 ± 0.008|
|
||||
|4.1.0|1.0.1|4.0.X|0.062 ± 0.008|0.208 ± 0.010|0.122 ± 0.003|
|
||||
|4.3.0|1.2.0|4.1.0|0.060 ± 0.006|0.208 ± 0.008|0.123 ± 0.008|
|
||||
|
||||
## TAR Info Function
|
||||
|
||||
|SWCompression<br>version|BitByteData<br>version|Test 1|Test 2|Test 3|
|
||||
|:---:|:---:|---|---|---|
|
||||
|4.0.0|—|0.248 ± 0.172|1.563 ± 0.442|1.254 ± 0.277|
|
||||
|4.0.1|—|0.187 ± 0.177|1.257 ± 0.404|1.016 ± 0.325|
|
||||
|4.1.0|1.0.1|0.194 ± 0.190|1.335 ± 0.475|1.062 ± 0.353|
|
||||
|SWCompression<br>version|BitByteData<br>version|Swift<br>version|Test 1|Test 2|Test 3|
|
||||
|:---:|:---:|:---:|---|---|---|
|
||||
|4.0.0|—|4.0.X|0.248 ± 0.172|1.563 ± 0.442|1.254 ± 0.277|
|
||||
|4.0.1|—|4.0.X|0.187 ± 0.177|1.257 ± 0.404|1.016 ± 0.325|
|
||||
|4.1.0|1.0.1|4.0.X|0.194 ± 0.190|1.335 ± 0.475|1.062 ± 0.353|
|
||||
|4.3.0|1.2.0|4.1.0|0.111 ± 0.008|1.014 ± 0.016|0.813 ± 0.015|
|
||||
|
||||
## ZIP Info Function
|
||||
|
||||
|SWCompression<br>version|BitByteData<br>version|Test 1|Test 2|Test 3|
|
||||
|:---:|:---:|---|---|---|
|
||||
|4.0.0|—|0.072 ± 0.065|0.669 ± 0.147|0.120 ± 0.081|
|
||||
|4.0.1|—|0.076 ± 0.064|0.670 ± 0.142|0.123 ± 0.080|
|
||||
|4.1.0|1.0.1|0.063 ± 0.076|0.148 ± 0.107|0.105 ± 0.089|
|
||||
|SWCompression<br>version|BitByteData<br>version|Swift<br>version|Test 1|Test 2|Test 3|
|
||||
|:---:|:---:|:---:|---|---|---|
|
||||
|4.0.0|—|4.0.X|0.072 ± 0.065|0.669 ± 0.147|0.120 ± 0.081|
|
||||
|4.0.1|—|4.0.X|0.076 ± 0.064|0.670 ± 0.142|0.123 ± 0.080|
|
||||
|4.1.0|1.0.1|4.0.X|0.063 ± 0.076|0.148 ± 0.107|0.105 ± 0.089|
|
||||
|4.3.0|1.2.0|4.1.0|0.044 ± 0.007|0.122 ± 0.009|0.086 ± 0.008|
|
||||
@@ -15,6 +15,9 @@ class TarTests: XCTestCase {
|
||||
XCTFail("Unable to get test data.")
|
||||
return
|
||||
}
|
||||
|
||||
XCTAssertEqual(try TarContainer.formatOf(container: testData), .ustar)
|
||||
|
||||
let result = try TarContainer.open(container: testData)
|
||||
|
||||
XCTAssertEqual(result.count, 1)
|
||||
@@ -29,6 +32,9 @@ class TarTests: XCTestCase {
|
||||
XCTFail("Unable to get test data.")
|
||||
return
|
||||
}
|
||||
|
||||
XCTAssertEqual(try TarContainer.formatOf(container: testData), .pax)
|
||||
|
||||
let result = try TarContainer.open(container: testData)
|
||||
|
||||
XCTAssertEqual(result.count, 5)
|
||||
@@ -62,6 +68,19 @@ class TarTests: XCTestCase {
|
||||
XCTFail("Unable to get test data.")
|
||||
return
|
||||
}
|
||||
|
||||
if testName == "test_gnu" {
|
||||
XCTAssertEqual(try TarContainer.formatOf(container: testData), .ustar)
|
||||
} else if testName == "test_oldgnu" {
|
||||
XCTAssertEqual(try TarContainer.formatOf(container: testData), .ustar)
|
||||
} else if testName == "test_pax" {
|
||||
XCTAssertEqual(try TarContainer.formatOf(container: testData), .pax)
|
||||
} else if testName == "test_ustar" {
|
||||
XCTAssertEqual(try TarContainer.formatOf(container: testData), .ustar)
|
||||
} else if testName == "test_v7" {
|
||||
XCTAssertEqual(try TarContainer.formatOf(container: testData), .prePosix)
|
||||
}
|
||||
|
||||
let result = try TarContainer.open(container: testData)
|
||||
|
||||
XCTAssertEqual(result.count, 1)
|
||||
@@ -80,6 +99,15 @@ class TarTests: XCTestCase {
|
||||
XCTFail("Unable to get test data.")
|
||||
return
|
||||
}
|
||||
|
||||
if testName == "long_test_gnu" {
|
||||
XCTAssertEqual(try TarContainer.formatOf(container: testData), .gnu)
|
||||
} else if testName == "long_test_oldgnu" {
|
||||
XCTAssertEqual(try TarContainer.formatOf(container: testData), .gnu)
|
||||
} else if testName == "long_test_pax" {
|
||||
XCTAssertEqual(try TarContainer.formatOf(container: testData), .pax)
|
||||
}
|
||||
|
||||
let result = try TarContainer.open(container: testData)
|
||||
|
||||
XCTAssertEqual(result.count, 6)
|
||||
@@ -91,6 +119,9 @@ class TarTests: XCTestCase {
|
||||
XCTFail("Unable to get test data.")
|
||||
return
|
||||
}
|
||||
|
||||
XCTAssertEqual(try TarContainer.formatOf(container: testData), .ustar)
|
||||
|
||||
let entries = try TarContainer.open(container: testData)
|
||||
|
||||
XCTAssertEqual(entries.count, 2)
|
||||
@@ -111,6 +142,9 @@ class TarTests: XCTestCase {
|
||||
XCTFail("Unable to get test data.")
|
||||
return
|
||||
}
|
||||
|
||||
XCTAssertEqual(try TarContainer.formatOf(container: testData), .ustar)
|
||||
|
||||
let entries = try TarContainer.open(container: testData)
|
||||
|
||||
XCTAssertEqual(entries.count, 1)
|
||||
@@ -125,6 +159,9 @@ class TarTests: XCTestCase {
|
||||
XCTFail("Unable to get test data.")
|
||||
return
|
||||
}
|
||||
|
||||
XCTAssertEqual(try TarContainer.formatOf(container: testData), .ustar)
|
||||
|
||||
let entries = try TarContainer.open(container: testData)
|
||||
|
||||
XCTAssertEqual(entries.count, 1)
|
||||
@@ -139,6 +176,9 @@ class TarTests: XCTestCase {
|
||||
XCTFail("Unable to get test data.")
|
||||
return
|
||||
}
|
||||
|
||||
XCTAssertEqual(try TarContainer.formatOf(container: testData), .prePosix)
|
||||
|
||||
let entries = try TarContainer.open(container: testData)
|
||||
|
||||
XCTAssertEqual(entries.isEmpty, true)
|
||||
@@ -150,6 +190,8 @@ class TarTests: XCTestCase {
|
||||
return
|
||||
}
|
||||
|
||||
XCTAssertEqual(try TarContainer.formatOf(container: testData), .ustar)
|
||||
|
||||
_ = try TarContainer.info(container: testData)
|
||||
_ = try TarContainer.open(container: testData)
|
||||
}
|
||||
|
||||
+1
-1
Submodule Tests/Test Files updated: 61fd50861a...3c2f771645.
@@ -0,0 +1,25 @@
|
||||
// Copyright (c) 2018 Timofey Solomko
|
||||
// Licensed under MIT License
|
||||
//
|
||||
// See LICENSE for license information
|
||||
|
||||
import Foundation
|
||||
import BitByteData
|
||||
import SWCompression
|
||||
|
||||
struct TestZipExtraField: ZipExtraField {
|
||||
|
||||
static let id: UInt16 = 0x0646
|
||||
|
||||
let size: Int
|
||||
let location: ZipExtraFieldLocation
|
||||
|
||||
var helloString: String?
|
||||
|
||||
init(_ byteReader: ByteReader, _ size: Int, location: ZipExtraFieldLocation) {
|
||||
self.size = size
|
||||
self.location = location
|
||||
self.helloString = String(data: Data(bytes: byteReader.bytes(count: size)), encoding: .utf8)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,6 +19,41 @@ class ZipTests: XCTestCase {
|
||||
_ = try ZipContainer.open(container: testData)
|
||||
}
|
||||
|
||||
func testZipCustomExtraField() throws {
|
||||
guard let testData = Constants.data(forTest: "test_custom_extra_field", withType: ZipTests.testType) else {
|
||||
XCTFail("Unable to get test data.")
|
||||
return
|
||||
}
|
||||
|
||||
// First, we check that without enabling support for our custom extra field, ZipContainer doesn't recognize it.
|
||||
var result = try ZipContainer.open(container: testData)
|
||||
XCTAssertEqual(result.count, 1)
|
||||
XCTAssertEqual(result[0].info.customExtraFields.count, 0)
|
||||
|
||||
// Enable support for custom extra field.
|
||||
ZipContainer.customExtraFields[0x0646] = TestZipExtraField.self
|
||||
|
||||
result = try ZipContainer.open(container: testData)
|
||||
XCTAssertEqual(result.count, 1)
|
||||
|
||||
let entry = result[0]
|
||||
XCTAssertEqual(entry.info.customExtraFields.count, 2)
|
||||
|
||||
for customExtraField in entry.info.customExtraFields {
|
||||
XCTAssertTrue(customExtraField is TestZipExtraField)
|
||||
XCTAssertEqual(customExtraField.id, TestZipExtraField.id)
|
||||
if customExtraField.size == 13 {
|
||||
XCTAssertEqual(customExtraField.location, .centralDirectory)
|
||||
XCTAssertEqual((customExtraField as? TestZipExtraField)?.helloString, "Hello, Extra!")
|
||||
} else if customExtraField.size == 20 {
|
||||
XCTAssertEqual(customExtraField.location, .localHeader)
|
||||
XCTAssertEqual((customExtraField as? TestZipExtraField)?.helloString, "Hello, Local Header!")
|
||||
} else {
|
||||
XCTFail("Wrong size for custom extra field.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testZip64() throws {
|
||||
guard let testData = Constants.data(forTest: "test_zip64", withType: ZipTests.testType) else {
|
||||
XCTFail("Unable to get test data.")
|
||||
|
||||
Reference in new issue
Block a user