Added changes left out in last commit.

Users can now provide a callback to retrieve real-time statistics on
the progress of zipping files.
This commit is contained in:
David Evans
2017-01-21 18:29:28 +00:00
parent 0c98af7f9e
commit 97cd6424fd
+7 -1
View File
@@ -537,8 +537,10 @@
// use a local filemanager (queue/thread compatibility)
fileManager = [[NSFileManager alloc] init];
NSDirectoryEnumerator *dirEnumerator = [fileManager enumeratorAtPath:directoryPath];
NSArray *allObjects = dirEnumerator.allObjects;
NSUInteger total = allObjects.count, complete = 0;
NSString *fileName;
while ((fileName = [dirEnumerator nextObject])) {
for (fileName in allObjects) {
BOOL isDir;
NSString *fullFilePath = [directoryPath stringByAppendingPathComponent:fileName];
[fileManager fileExistsAtPath:fullFilePath isDirectory:&isDir];
@@ -560,6 +562,10 @@
[zipArchive writeFileAtPath:tempFilePath withFileName:tempFileFilename withPassword:password];
}
}
complete++;
if (progressHandler) {
progressHandler(complete, total);
}
}
success = [zipArchive close];
}