Commit 7491daac authored by Roy Marmelstein's avatar Roy Marmelstein

Easier/safer access to filePath in processed file struct

parent 065b28c2
......@@ -207,12 +207,11 @@ public class Zip {
// Get totalSize for progress handler
for path in processedPaths {
do {
if let filePath = path.filePathURL.path {
let fileAttributes = try fileManager.attributesOfItemAtPath(filePath)
let fileSize = fileAttributes[NSFileSize] as? Double
if let fileSize = fileSize {
totalSize += fileSize
}
let filePath = path.filePath()
let fileAttributes = try fileManager.attributesOfItemAtPath(filePath)
let fileSize = fileAttributes[NSFileSize] as? Double
if let fileSize = fileSize {
totalSize += fileSize
}
}
catch {}
......@@ -221,9 +220,7 @@ public class Zip {
// Begin Zipping
let zip = zipOpen(destinationPath, APPEND_STATUS_CREATE)
for path in processedPaths {
guard let filePath = path.filePathURL.path else {
throw ZipError.ZipFail
}
let filePath = path.filePath()
var isDirectory: ObjCBool = false
fileManager.fileExistsAtPath(filePath, isDirectory: &isDirectory)
if !isDirectory {
......
......@@ -19,6 +19,15 @@ internal class ZipUtilities {
internal struct ProcessedFilePath {
let filePathURL: NSURL
let fileName: String?
func filePath() -> String {
if let filePath = filePathURL.path {
return filePath
}
else {
return String()
}
}
}
//MARK: Path processing
......
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