Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding back the old method UnzipFileTo:overwrite for backwards compat…

…ibility.
  • Loading branch information...
commit 999737707ee00def04f0b7cfa54e00a4c646f1c2 1 parent ad97994
@mattconnolly authored
Showing with 33 additions and 3 deletions.
  1. +10 −2 ZipArchive.h
  2. +23 −1 ZipArchive.m
View
12 ZipArchive.h
@@ -16,6 +16,14 @@
/**
+ a block that is called from UnzipFileTo:overwrite:withProgressBlock: where the percentage of
+ files processed (as an integer from 0 to 100), the number of files processed so far and the
+ total number of files in the archive is called after each file is processed.
+ */
+typedef void(^ZipArchiveProgressUpdateBlock)(int percentage, int filesProcessed, int numFiles);
+
+
+/**
@protocol
@discussion methods for a delegate to receive error notifications and control overwriting of files
*/
@@ -85,10 +93,10 @@
-(BOOL) UnzipOpenFile:(NSString*) zipFile;
-(BOOL) UnzipOpenFile:(NSString*) zipFile Password:(NSString*) password;
+-(BOOL) UnzipFileTo:(NSString*) path overWrite:(BOOL) overwrite;
-(BOOL) UnzipFileTo:(NSString*) path
overWrite:(BOOL) overwrite
- withProgressBlock:(void (^)(int percentage /* 0-100 */, int filesProcessed, int numFiles))progressBlock;
+ withProgressBlock:(ZipArchiveProgressUpdateBlock)progressBlock;
-(BOOL) UnzipCloseFile;
-(NSArray*) getZipFileContents; // list the contents of the zip archive. must be called after UnzipOpenFile
-
@end
View
24 ZipArchive.m
@@ -225,6 +225,28 @@ -(BOOL) UnzipOpenFile:(NSString*) zipFile Password:(NSString*) password
return [self UnzipOpenFile:zipFile];
}
+
+/**
+ * Expand all files in the zip archive into the specified directory.
+ *
+ * If a delegate has been set and responds to OverWriteOperation: it can
+ * return YES to overwrite a file, or NO to skip that file.
+ *
+ * On completion, the property `unzippedFiles` will be an array populated
+ * with the full paths of each file that was successfully expanded.
+ *
+ * @param path the directory where expanded files will be created
+ * @param overwrite should existing files be overwritten
+ * @returns BOOL YES on success
+ */
+
+-(BOOL) UnzipFileTo:(NSString*) path overWrite:(BOOL) overwrite
+{
+ return [self UnzipFileTo:path
+ overWrite:overwrite
+ withProgressBlock:nil];
+}
+
/**
* Expand all files in the zip archive into the specified directory.
*
@@ -241,7 +263,7 @@ -(BOOL) UnzipOpenFile:(NSString*) zipFile Password:(NSString*) password
* @returns BOOL YES on success
*/
--(BOOL) UnzipFileTo:(NSString*) path overWrite:(BOOL) overwrite withProgressBlock:(void (^)(int percentage, int filesProcessed, int numFiles))progressBlock
+-(BOOL) UnzipFileTo:(NSString*) path overWrite:(BOOL) overwrite withProgressBlock:(ZipArchiveProgressUpdateBlock)progressBlock
{
BOOL success = YES;
int index = 0;
Please sign in to comment.
Something went wrong with that request. Please try again.