Commit a34b598d authored by Mostafa Berg's avatar Mostafa Berg

+Updated Zip/*.siwft files to User Swift 3.0

+Updated Schemes to follow XCode 8's recommended settings
parent 3b9765a3
......@@ -493,7 +493,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0720;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "Roy Marmelstein";
TargetAttributes = {
343F50FE1C8DAEEC0028C434 = {
......@@ -504,9 +504,11 @@
};
347E3A731C1DFFB500A11FD3 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
};
347E3A7D1C1DFFB500A11FD3 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
};
};
};
......@@ -714,6 +716,7 @@
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "appletvsimulator appletvos";
SWIFT_INCLUDE_PATHS = "${SRCROOT}/Zip/minizip/**";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
......@@ -762,6 +765,7 @@
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_INCLUDE_PATHS = "${SRCROOT}/Zip/minizip/**";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
};
name = Release;
};
......@@ -901,6 +905,7 @@
SKIP_INSTALL = YES;
SWIFT_INCLUDE_PATHS = "${SRCROOT}/Zip/minizip/**";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
......@@ -922,6 +927,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_INCLUDE_PATHS = "${SRCROOT}/Zip/minizip/**";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
};
name = Release;
};
......@@ -932,6 +939,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.roymarmelstein.ZipTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
......@@ -942,6 +950,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.roymarmelstein.ZipTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
};
name = Release;
};
......
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
......
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
......
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
......
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
......
......@@ -21,7 +21,7 @@ extension Zip {
- returns: NSURL of the destination folder.
*/
public class func quickUnzipFile(path: NSURL) throws -> NSURL {
public class func quickUnzipFile(_ path: URL) throws -> URL {
return try quickUnzipFile(path, progress: nil)
}
......@@ -37,16 +37,20 @@ extension Zip {
- returns: NSURL of the destination folder.
*/
public class func quickUnzipFile(path: NSURL, progress: ((progress: Double) -> ())?) throws -> NSURL {
let fileManager = NSFileManager.defaultManager()
public class func quickUnzipFile(_ path: URL, progress: ((progress: Double) -> ())?) throws -> URL {
let fileManager = FileManager.default
guard let fileExtension = path.pathExtension, let fileName = path.lastPathComponent else {
throw ZipError.UnzipFail
throw ZipError.unzipFail
}
let directoryName = fileName.replacingOccurrences(of: ".\(fileExtension)", with: "")
let documentsUrl = fileManager.urlsForDirectory(.documentDirectory, inDomains: .userDomainMask)[0] as URL
do {
let destinationUrl = try documentsUrl.appendingPathComponent(directoryName, isDirectory: true)
try self.unzipFile(path, destination: destinationUrl, overwrite: true, password: nil, progress: progress)
return destinationUrl
}catch{
throw(ZipError.unzipFail)
}
let directoryName = fileName.stringByReplacingOccurrencesOfString(".\(fileExtension)", withString: "")
let documentsUrl = fileManager.URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0] as NSURL
let destinationUrl = documentsUrl.URLByAppendingPathComponent(directoryName, isDirectory: true)
try self.unzipFile(path, destination: destinationUrl, overwrite: true, password: nil, progress: progress)
return destinationUrl
}
//MARK: Quick Zip
......@@ -63,7 +67,7 @@ extension Zip {
- returns: NSURL of the destination folder.
*/
public class func quickZipFiles(paths: [NSURL], fileName: String) throws -> NSURL {
public class func quickZipFiles(_ paths: [URL], fileName: String) throws -> URL {
return try quickZipFiles(paths, fileName: fileName, progress: nil)
}
......@@ -80,13 +84,13 @@ extension Zip {
- returns: NSURL of the destination folder.
*/
public class func quickZipFiles(paths: [NSURL], fileName: String, progress: ((progress: Double) -> ())?) throws -> NSURL {
let fileManager = NSFileManager.defaultManager()
let documentsUrl = fileManager.URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0] as NSURL
let destinationUrl = documentsUrl.URLByAppendingPathComponent("\(fileName).zip")
public class func quickZipFiles(_ paths: [URL], fileName: String, progress: ((progress: Double) -> ())?) throws -> URL {
let fileManager = FileManager.default
let documentsUrl = fileManager.urlsForDirectory(.documentDirectory, inDomains: .userDomainMask)[0] as URL
let destinationUrl = try! documentsUrl.appendingPathComponent("\(fileName).zip")
try self.zipFiles(paths, zipFilePath: destinationUrl, password: nil, progress: progress)
return destinationUrl
}
}
\ No newline at end of file
}
This diff is collapsed.
......@@ -11,13 +11,13 @@ import Foundation
internal class ZipUtilities {
// File manager
let fileManager = NSFileManager.defaultManager()
let fileManager = FileManager.default
/**
* ProcessedFilePath struct
*/
internal struct ProcessedFilePath {
let filePathURL: NSURL
let filePathURL: URL
let fileName: String?
func filePath() -> String {
......@@ -39,21 +39,21 @@ internal class ZipUtilities {
- returns: Array of ProcessedFilePath structs.
*/
internal func processZipPaths(paths: [NSURL]) -> [ProcessedFilePath]{
internal func processZipPaths(_ paths: [URL]) -> [ProcessedFilePath]{
var processedFilePaths = [ProcessedFilePath]()
for path in paths {
guard let filePath = path.path else {
continue
}
var isDirectory: ObjCBool = false
fileManager.fileExistsAtPath(filePath, isDirectory: &isDirectory)
fileManager.fileExists(atPath: filePath, isDirectory: &isDirectory)
if !isDirectory {
let processedPath = ProcessedFilePath(filePathURL: path, fileName: path.lastPathComponent)
processedFilePaths.append(processedPath)
}
else {
let directoryContents = expandDirectoryFilePath(path)
processedFilePaths.appendContentsOf(directoryContents)
processedFilePaths.append(contentsOf: directoryContents)
}
}
return processedFilePaths
......@@ -67,28 +67,28 @@ internal class ZipUtilities {
- returns: Array of ProcessedFilePath structs.
*/
internal func expandDirectoryFilePath(directory: NSURL) -> [ProcessedFilePath] {
internal func expandDirectoryFilePath(_ directory: URL) -> [ProcessedFilePath] {
var processedFilePaths = [ProcessedFilePath]()
if let directoryPath = directory.path, let enumerator = fileManager.enumeratorAtPath(directoryPath) {
if let directoryPath = directory.path, let enumerator = fileManager.enumerator(atPath: directoryPath) {
while let filePathComponent = enumerator.nextObject() as? String {
let path = directory.URLByAppendingPathComponent(filePathComponent)
let path = try! directory.appendingPathComponent(filePathComponent)
guard let filePath = path.path, let directoryName = directory.lastPathComponent else {
continue
}
var isDirectory: ObjCBool = false
fileManager.fileExistsAtPath(filePath, isDirectory: &isDirectory)
fileManager.fileExists(atPath: filePath, isDirectory: &isDirectory)
if !isDirectory {
let fileName = (directoryName as NSString).stringByAppendingPathComponent(filePathComponent)
let fileName = (directoryName as NSString).appendingPathComponent(filePathComponent)
let processedPath = ProcessedFilePath(filePathURL: path, fileName: fileName)
processedFilePaths.append(processedPath)
}
else {
let directoryContents = expandDirectoryFilePath(path)
processedFilePaths.appendContentsOf(directoryContents)
processedFilePaths.append(contentsOf: directoryContents)
}
}
}
return processedFilePaths
}
}
\ No newline at end of file
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment