diff --git a/.jazzy.yaml b/.jazzy.yaml
index db7d4de5..9eddaeb7 100644
--- a/.jazzy.yaml
+++ b/.jazzy.yaml
@@ -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
diff --git a/.swift-version b/.swift-version
index 5186d070..7d5c902e 100644
--- a/.swift-version
+++ b/.swift-version
@@ -1 +1 @@
-4.0
+4.1
diff --git a/.swiftlint.yml b/.swiftlint.yml
index d750ba04..c9df412d 100644
--- a/.swiftlint.yml
+++ b/.swiftlint.yml
@@ -1,6 +1,7 @@
excluded:
- .build/
- Package.swift
+ - Carthage/
disabled_rules:
- cyclomatic_complexity
- file_length
diff --git a/.travis.yml b/.travis.yml
index 4c275405..58b6f94a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -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:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dddbb2e9..bba766f7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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.
diff --git a/Cartfile b/Cartfile
index ca433536..20558217 100644
--- a/Cartfile
+++ b/Cartfile
@@ -1 +1 @@
-github "tsolomko/BitByteData" ~> 1.1
+github "tsolomko/BitByteData" ~> 1.2
diff --git a/Package.swift b/Package.swift
index b096f43d..0da00ff9 100644
--- a/Package.swift
+++ b/Package.swift
@@ -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.
diff --git a/README.md b/README.md
index 23455135..ad77dd44 100644
--- a/README.md
+++ b/README.md
@@ -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`.
diff --git a/SWCompression.podspec b/SWCompression.podspec
index d089ab03..a0309604 100644
--- a/SWCompression.podspec
+++ b/SWCompression.podspec
@@ -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
diff --git a/SWCompression.xcodeproj/SWCompression.plist b/SWCompression.xcodeproj/SWCompression.plist
index 328506ea..f2425192 100644
--- a/SWCompression.xcodeproj/SWCompression.plist
+++ b/SWCompression.xcodeproj/SWCompression.plist
@@ -15,9 +15,9 @@
CFBundlePackageType
FMWK
CFBundleShortVersionString
- 4.2.2
+ 4.3.0
CFBundleVersion
- 59
+ 62
NSHumanReadableCopyright
Copyright © 2018 Timofey Solomko. All rights reserved.
diff --git a/SWCompression.xcodeproj/TestSWCompression.plist b/SWCompression.xcodeproj/TestSWCompression.plist
index 8b00954d..41412361 100644
--- a/SWCompression.xcodeproj/TestSWCompression.plist
+++ b/SWCompression.xcodeproj/TestSWCompression.plist
@@ -15,8 +15,8 @@
CFBundlePackageType
BNDL
CFBundleShortVersionString
- 4.2.2
+ 4.3.0
CFBundleVersion
- 59
+ 62
diff --git a/SWCompression.xcodeproj/project.pbxproj b/SWCompression.xcodeproj/project.pbxproj
index 84aed303..800d1067 100644
--- a/SWCompression.xcodeproj/project.pbxproj
+++ b/SWCompression.xcodeproj/project.pbxproj
@@ -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 = ""; };
06092A191FA4CB0300DE9FD5 /* CompressionMethod.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompressionMethod.swift; sourceTree = ""; };
06092A231FA4CC3D00DE9FD5 /* CompressionMethod+Zip.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CompressionMethod+Zip.swift"; sourceTree = ""; };
061C06201F0E89D900832F0C /* XZError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XZError.swift; sourceTree = ""; };
@@ -236,6 +241,7 @@
06393DF41F1A7F8E00A647A0 /* ZipString.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZipString.swift; sourceTree = ""; };
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 = ""; };
064492581DC606D400F10981 /* ZlibArchive.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZlibArchive.swift; sourceTree = ""; };
064512861F82CE63006490BA /* 7zCoder+Equatable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "7zCoder+Equatable.swift"; sourceTree = ""; };
064F72231F1E5D4400017297 /* 7zContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = 7zContainer.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
@@ -280,12 +286,14 @@
06CDFCA71F111D9700292758 /* DeflateError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeflateError.swift; sourceTree = ""; };
06CDFCAC1F111DBE00292758 /* LZMAError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LZMAError.swift; sourceTree = ""; };
06CDFCB11F111DEC00292758 /* LZMA2Error.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LZMA2Error.swift; sourceTree = ""; };
+ 06CFF6B12078C5A5003B8375 /* TarEntryInfoProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TarEntryInfoProvider.swift; sourceTree = ""; };
+ 06D42DA42067B46800C1A98B /* test_custom_extra_field.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = test_custom_extra_field.zip; sourceTree = ""; };
+ 06D42DA62067B71000C1A98B /* TestZipExtraField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestZipExtraField.swift; sourceTree = ""; };
06D95AC01F4C54E0006B46AC /* BZip2+Compress.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "BZip2+Compress.swift"; sourceTree = ""; };
06DDB1701F8190D400035BEF /* BZip2+BlockSize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BZip2+BlockSize.swift"; sourceTree = ""; };
06DE29B71FB7024C0098A761 /* ByteReader+ZipString.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ByteReader+ZipString.swift"; sourceTree = ""; };
06E2346B1E068E9600F18798 /* XZArchive.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XZArchive.swift; sourceTree = ""; };
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 = ""; };
@@ -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 = "";
@@ -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 = "";
@@ -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;
diff --git a/SWCompression.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/SWCompression.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 00000000..18d98100
--- /dev/null
+++ b/SWCompression.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/SWCompression.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/SWCompression.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
new file mode 100644
index 00000000..3ddf867a
--- /dev/null
+++ b/SWCompression.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
@@ -0,0 +1,8 @@
+
+
+
+
+ BuildSystemType
+ Latest
+
+
diff --git a/SWCompression.xcodeproj/xcshareddata/xcschemes/SWCompression.xcscheme b/SWCompression.xcodeproj/xcshareddata/xcschemes/SWCompression.xcscheme
index c481b3e4..a7095ec1 100644
--- a/SWCompression.xcodeproj/xcshareddata/xcschemes/SWCompression.xcscheme
+++ b/SWCompression.xcodeproj/xcshareddata/xcschemes/SWCompression.xcscheme
@@ -1,6 +1,6 @@
= 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
diff --git a/Sources/7-Zip/7zEntryInfo.swift b/Sources/7-Zip/7zEntryInfo.swift
index 36574eb9..b89947f2 100644
--- a/Sources/7-Zip/7zEntryInfo.swift
+++ b/Sources/7-Zip/7zEntryInfo.swift
@@ -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
diff --git a/Sources/7-Zip/7zFileInfo.swift b/Sources/7-Zip/7zFileInfo.swift
index b4f02976..b4c1d375 100644
--- a/Sources/7-Zip/7zFileInfo.swift
+++ b/Sources/7-Zip/7zFileInfo.swift
@@ -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.. 0 {
- let digitsNumber = floor(log2(Double(lengthOfZerosRun) + 1))
+ let digitsNumber = Int(floor(log2(Double(lengthOfZerosRun) + 1)))
var remainder = lengthOfZerosRun
- for _ in 0..>= 1
}
- self.tree[index] = length.symbol
+ tree[index] = length.symbol
}
+ self.tree = tree
}
func findNextSymbol() -> Int {
diff --git a/Sources/Common/EncodingHuffmanTree.swift b/Sources/Common/EncodingHuffmanTree.swift
index 3ad5f1ca..f7bd5627 100644
--- a/Sources/Common/EncodingHuffmanTree.swift
+++ b/Sources/Common/EncodingHuffmanTree.swift
@@ -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) {
diff --git a/Sources/Common/Extensions.swift b/Sources/Common/Extensions.swift
index 318a9d7e..556d36d4 100644
--- a/Sources/Common/Extensions.swift
+++ b/Sources/Common/Extensions.swift
@@ -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)
}
}
diff --git a/Sources/Common/HuffmanLength+Comparable.swift b/Sources/Common/HuffmanLength+Comparable.swift
deleted file mode 100644
index 773a5f19..00000000
--- a/Sources/Common/HuffmanLength+Comparable.swift
+++ /dev/null
@@ -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
- }
-
-}
diff --git a/Sources/Common/HuffmanLength.swift b/Sources/Common/HuffmanLength.swift
index 228eadf5..a5200d75 100644
--- a/Sources/Common/HuffmanLength.swift
+++ b/Sources/Common/HuffmanLength.swift
@@ -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
+ }
+ }
+
+}
diff --git a/Sources/GZip/GzipArchive.swift b/Sources/GZip/GzipArchive.swift
index 6703e58f..76981b62 100644
--- a/Sources/GZip/GzipArchive.swift
+++ b/Sources/GZip/GzipArchive.swift
@@ -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 }
diff --git a/Sources/LZMA/LZMA.swift b/Sources/LZMA/LZMA.swift
index 0ace6881..a4b3c4ab 100644
--- a/Sources/LZMA/LZMA.swift
+++ b/Sources/LZMA/LZMA.swift
@@ -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 {
diff --git a/Sources/LZMA2/LZMA2Decoder.swift b/Sources/LZMA2/LZMA2Decoder.swift
index 6fc08f34..b1c41884 100644
--- a/Sources/LZMA2/LZMA2Decoder.swift
+++ b/Sources/LZMA2/LZMA2Decoder.swift
@@ -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()
diff --git a/Sources/TAR/ByteReader+Tar.swift b/Sources/TAR/ByteReader+Tar.swift
index fb9ebc1e..81eac888 100644
--- a/Sources/TAR/ByteReader+Tar.swift
+++ b/Sources/TAR/ByteReader+Tar.swift
@@ -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
}
diff --git a/Sources/TAR/TarContainer.swift b/Sources/TAR/TarContainer.swift
index ebf3ad8b..7ef842e8 100644
--- a/Sources/TAR/TarContainer.swift
+++ b/Sources/TAR/TarContainer.swift
@@ -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.. TarEntryInfo? {
+ guard byteReader.bytesLeft >= 1024,
+ byteReader.data[byteReader.offset.. 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)
+ }
+ }
+
+}
diff --git a/Sources/ZIP/ZipCentralDirectoryEntry.swift b/Sources/ZIP/ZipCentralDirectoryEntry.swift
index 79d80177..e620b1bb 100644
--- a/Sources/ZIP/ZipCentralDirectoryEntry.swift
+++ b/Sources/ZIP/ZipCentralDirectoryEntry.swift
@@ -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.. 8 {
- byteReader.offset += gidSize
- } else {
- var gid = 0
- for i in 0..