Permalink
Browse files

initial zip decode tests

  • Loading branch information...
atomicguy committed Oct 2, 2018
1 parent 25b1c8a commit a38fbc9c855af31ab0dbb496121108e0044d2fef
@@ -49,6 +49,7 @@
41D4F2EB2101A278009F1B1E /* DirectoryWatcher.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 41D4F2EA2101A278009F1B1E /* DirectoryWatcher.framework */; };
41D4F2EF21053944009F1B1E /* IndexPath+BookPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41D4F2EE21053944009F1B1E /* IndexPath+BookPlayer.swift */; };
41E34E502138EA8200A3997C /* ImportOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41E34E4F2138EA8200A3997C /* ImportOperation.swift */; };
5CBB29542163A33800E3A9FF /* ZIPFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5CBB29522163A17F00E3A9FF /* ZIPFoundation.framework */; };
69343D332133844D000C425E /* VoiceOverService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69343D322133844D000C425E /* VoiceOverService.swift */; };
69343D36213A07B4000C425E /* VoiceOverServiceTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69343D35213A07B4000C425E /* VoiceOverServiceTest.swift */; };
C30B085F209654E3003F325B /* UIColor+BookPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = C30B085E209654E3003F325B /* UIColor+BookPlayer.swift */; };
@@ -162,6 +163,7 @@
41D4F2EA2101A278009F1B1E /* DirectoryWatcher.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DirectoryWatcher.framework; path = Carthage/Build/iOS/DirectoryWatcher.framework; sourceTree = "<group>"; };
41D4F2EE21053944009F1B1E /* IndexPath+BookPlayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "IndexPath+BookPlayer.swift"; sourceTree = "<group>"; };
41E34E4F2138EA8200A3997C /* ImportOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImportOperation.swift; sourceTree = "<group>"; };
5CBB29522163A17F00E3A9FF /* ZIPFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ZIPFoundation.framework; path = Carthage/Build/iOS/ZIPFoundation.framework; sourceTree = "<group>"; };
69343D322133844D000C425E /* VoiceOverService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoiceOverService.swift; sourceTree = "<group>"; };
69343D35213A07B4000C425E /* VoiceOverServiceTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoiceOverServiceTest.swift; sourceTree = "<group>"; };
C30B085E209654E3003F325B /* UIColor+BookPlayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+BookPlayer.swift"; sourceTree = "<group>"; };
@@ -217,6 +219,7 @@
C30CD2A32097C49F00258B09 /* ColorCube.framework in Frameworks */,
4165EE0E20A7AEC600616EDF /* SwiftReorder.framework in Frameworks */,
412451841D489204008AC0E5 /* Crashlytics.framework in Frameworks */,
5CBB29542163A33800E3A9FF /* ZIPFoundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -312,6 +315,7 @@
41AABFFA1E705D18006BD2E0 /* Frameworks */ = {
isa = PBXGroup;
children = (
5CBB29522163A17F00E3A9FF /* ZIPFoundation.framework */,
41D4F2EA2101A278009F1B1E /* DirectoryWatcher.framework */,
4150F80220A8DC34002EDB08 /* IDZSwiftCommonCrypto.framework */,
4165EE0D20A7AEC600616EDF /* SwiftReorder.framework */,
@@ -20,6 +20,16 @@
<string>public.audio</string>
</array>
</dict>
<dict>
<key>CFBundleTypeIconFiles</key>
<array/>
<key>CFBundleTypeName</key>
<string>Audiobook Archive</string>
<key>LSItemContentTypes</key>
<array>
<string>com.pkware.zip-archive</string>
</array>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
@@ -8,6 +8,7 @@
import Foundation
import IDZSwiftCommonCrypto
import ZIPFoundation

/**
Process files located at a specific `URL`, renames it with the hash and moves it to the specified destination folder.
@@ -30,6 +31,20 @@ class ImportOperation: Operation {

NotificationCenter.default.post(name: .processingFile, object: self, userInfo: ["filename": file.originalUrl.lastPathComponent])

if file.originalUrl.lastPathComponent == "zip" {
inputStream.open()
let fileManager = FileManager()
let currentWorkingPath = fileManager.currentDirectoryPath
var destinationURL = URL(fileURLWithPath: currentWorkingPath)
destinationURL.appendPathComponent("directory")
do {
try fileManager.createDirectory(at: destinationURL, withIntermediateDirectories: true, attributes: nil)
try fileManager.unzipItem(at: file.originalUrl, to: destinationURL)
} catch {
print("Extraction of ZIP archive failed with error:\(error)")
}
}

inputStream.open()

let digest = Digest(algorithm: .md5)
@@ -4,3 +4,4 @@ github "dennisweissmann/DeviceKit" ~> 1.7
github "GianniCarlo/SwiftReorder"
github "iosdevzone/IDZSwiftCommonCrypto"
github "GianniCarlo/DirectoryWatcher"
github "weichsel/ZIPFoundation" ~> 0.9

0 comments on commit a38fbc9

Please sign in to comment.