From 713835cc28b896938dc5fe739a611f2e87553bec Mon Sep 17 00:00:00 2001 From: Chris Stevenson Date: Wed, 1 Aug 2012 15:03:29 -0700 Subject: [PATCH 1/7] Add a delegate method that will report the file names of files that were unzipped --- SSZipArchive.h | 1 + SSZipArchive.m | 5 ++- Tests/CollectingDelegate.h | 8 +++++ Tests/CollectingDelegate.m | 35 ++++++++++++++++++++ Tests/SSZipArchive.xcodeproj/project.pbxproj | 6 ++++ Tests/SSZipArchiveTests.m | 11 ++++++ 6 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 Tests/CollectingDelegate.h create mode 100644 Tests/CollectingDelegate.m diff --git a/SSZipArchive.h b/SSZipArchive.h index fb8d055..cb3a168 100644 --- a/SSZipArchive.h +++ b/SSZipArchive.h @@ -42,4 +42,5 @@ - (void)zipArchiveWillUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo; - (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo; +- (void)zipArchiveDidUnzipArchiveFile:(NSString *)zipFile entryPath:(NSString *)entryPath destPath:(NSString *)destPath; @end diff --git a/SSZipArchive.m b/SSZipArchive.m index 93693f5..d4e3cc2 100644 --- a/SSZipArchive.m +++ b/SSZipArchive.m @@ -240,7 +240,10 @@ [delegate zipArchiveDidUnzipFileAtIndex:currentFileNumber totalFiles:(NSInteger)globalInfo.number_entry archivePath:path fileInfo:fileInfo]; } - + if ([delegate respondsToSelector:@selector(zipArchiveDidUnzipArchiveFile:entryPath:destPath:)]) { + [delegate zipArchiveDidUnzipArchiveFile:path entryPath:strPath destPath:fullPath]; + } + currentFileNumber++; } while(ret == UNZ_OK && UNZ_OK != UNZ_END_OF_LIST_OF_FILE); diff --git a/Tests/CollectingDelegate.h b/Tests/CollectingDelegate.h new file mode 100644 index 0000000..ce56265 --- /dev/null +++ b/Tests/CollectingDelegate.h @@ -0,0 +1,8 @@ +#import + +/** +* Test delegate by collecting its calls +*/ +@interface CollectingDelegate : NSObject +@property(nonatomic, retain) NSMutableArray *files; +@end \ No newline at end of file diff --git a/Tests/CollectingDelegate.m b/Tests/CollectingDelegate.m new file mode 100644 index 0000000..0d9e5e0 --- /dev/null +++ b/Tests/CollectingDelegate.m @@ -0,0 +1,35 @@ +// +// Created by chris on 8/1/12. +// +// To change the template use AppCode | Preferences | File Templates. +// + + +#import "SSZipArchive.h" +#import "CollectingDelegate.h" + +@implementation CollectingDelegate { + +} +@synthesize files = _files; + + +- (id)init { + self = [super init]; + if (self) { + self.files = [NSMutableArray array]; + } + return self; +} + +- (void)zipArchiveDidUnzipArchiveFile:(NSString *)zipFile entryPath:(NSString *)entryPath destPath:(NSString *)destPath { + [self.files addObject:entryPath]; +} + +- (void)dealloc { + [_files release]; + [super dealloc]; +} + + +@end \ No newline at end of file diff --git a/Tests/SSZipArchive.xcodeproj/project.pbxproj b/Tests/SSZipArchive.xcodeproj/project.pbxproj index 04fbae8..b385f39 100644 --- a/Tests/SSZipArchive.xcodeproj/project.pbxproj +++ b/Tests/SSZipArchive.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 5A416BA09CD6A335F551C015 /* CollectingDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 5A416109F75BF6E777908B04 /* CollectingDelegate.m */; }; B215FB32143AD3C7003AC546 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B215FB31143AD3C7003AC546 /* SenTestingKit.framework */; }; B215FB63143AD514003AC546 /* SSZipArchiveTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B215FB61143AD514003AC546 /* SSZipArchiveTests.m */; }; B215FB65143AD527003AC546 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = B215FB64143AD527003AC546 /* libz.dylib */; }; @@ -24,6 +25,8 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 5A416109F75BF6E777908B04 /* CollectingDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CollectingDelegate.m; sourceTree = ""; }; + 5A4164B83A2827BFD88C3CA1 /* CollectingDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CollectingDelegate.h; sourceTree = ""; }; B215FB18143AD3C7003AC546 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; B215FB30143AD3C7003AC546 /* SSZipArchiveTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SSZipArchiveTests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; B215FB31143AD3C7003AC546 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; @@ -120,6 +123,8 @@ B215FB5E143AD505003AC546 /* SSZipArchiveTests */ = { isa = PBXGroup; children = ( + 5A416109F75BF6E777908B04 /* CollectingDelegate.m */, + 5A4164B83A2827BFD88C3CA1 /* CollectingDelegate.h */, B2283D5C155AD80F00F9395A /* Unicode.zip */, B215FB61143AD514003AC546 /* SSZipArchiveTests.m */, B215FB5F143AD514003AC546 /* SSZipArchiveTests-Info.plist */, @@ -220,6 +225,7 @@ B215FB69143AD576003AC546 /* mztools.c in Sources */, B215FB6A143AD576003AC546 /* unzip.c in Sources */, B215FB6B143AD576003AC546 /* zip.c in Sources */, + 5A416BA09CD6A335F551C015 /* CollectingDelegate.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Tests/SSZipArchiveTests.m b/Tests/SSZipArchiveTests.m index bc45c64..d6f1d9d 100644 --- a/Tests/SSZipArchiveTests.m +++ b/Tests/SSZipArchiveTests.m @@ -7,6 +7,7 @@ // #import "SSZipArchive.h" +#import "CollectingDelegate.h" #import #import @@ -131,6 +132,16 @@ // [SSZipArchive unzipFileAtPath:zipPath toDestination:outputPath]; //} +-(void)testShouldProvidePathOfUnzippedFileInDelegateCallback { + CollectingDelegate *collector = [[CollectingDelegate new] autorelease]; + NSString *zipPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestArchive" ofType:@"zip"]; + NSString *outputPath = [self _cachesPath:@"Regular"]; + + [SSZipArchive unzipFileAtPath:zipPath toDestination:outputPath delegate:collector]; + + STAssertEqualObjects([collector.files objectAtIndex:0], @"LICENSE", nil); + STAssertEqualObjects([collector.files objectAtIndex:1], @"Readme.markdown", nil); +} #pragma mark - SSZipArchiveDelegate From 3e2424437f4001b5ab616b984253338bcbcb4471 Mon Sep 17 00:00:00 2001 From: Chris Stevenson Date: Wed, 1 Aug 2012 15:06:50 -0700 Subject: [PATCH 2/7] Bump the pod version number --- SSZipArchive.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SSZipArchive.podspec b/SSZipArchive.podspec index 9eb41d5..7dd5c60 100644 --- a/SSZipArchive.podspec +++ b/SSZipArchive.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'SSZipArchive' - s.version = '0.2.2' + s.version = '0.2.3' s.summary = 'Utility class for zipping and unzipping files on iOS and Mac.' s.homepage = 'https://github.com/samsoffes/ssziparchive' s.author = { 'Sam Soffes' => 'sam@samsoff.es' } From a53f90839291ddf324d9d3eb3fe095a027dde68b Mon Sep 17 00:00:00 2001 From: David Robles Date: Thu, 16 Aug 2012 15:04:59 -0700 Subject: [PATCH 3/7] Update pod spec to prevent *.podspec file from being included as a source file when the pod is installed. --- SSZipArchive.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SSZipArchive.podspec b/SSZipArchive.podspec index 7dd5c60..0bb1a21 100644 --- a/SSZipArchive.podspec +++ b/SSZipArchive.podspec @@ -6,7 +6,7 @@ Pod::Spec.new do |s| s.author = { 'Sam Soffes' => 'sam@samsoff.es' } s.source = { :git => 'https://github.com/samsoffes/ssziparchive.git', :tag => '0.2.2' } s.description = 'SSZipArchive is a simple utility class for zipping and unzipping files on iOS and Mac.' - s.source_files = 'SSZipArchive.*', 'minizip/*.{h,c}' + s.source_files = 'SSZipArchive.{h,m}', 'minizip/*.{h,c}' s.library = 'z' s.preserve_paths = ['Tests', '.gitignore'] s.license = { :type => 'MIT', :file => 'LICENSE' } From ce6cbe1193b95251da5f5d01dd0618a6b87d8fb0 Mon Sep 17 00:00:00 2001 From: David Robles Date: Tue, 20 Aug 2013 10:57:34 -0700 Subject: [PATCH 4/7] Update out of date pod spec. --- SSZipArchive.podspec | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/SSZipArchive.podspec b/SSZipArchive.podspec index 0bb1a21..4a0c3ac 100644 --- a/SSZipArchive.podspec +++ b/SSZipArchive.podspec @@ -10,9 +10,4 @@ Pod::Spec.new do |s| s.library = 'z' s.preserve_paths = ['Tests', '.gitignore'] s.license = { :type => 'MIT', :file => 'LICENSE' } - - # Maintain the dir structure for headers - def s.copy_header_mapping(from) - from - end -end + s.header_mappings_dir = '.' From d30b543f34d54bb682eabe2865ce1e453856e6b2 Mon Sep 17 00:00:00 2001 From: David Robles Date: Tue, 20 Aug 2013 11:52:03 -0700 Subject: [PATCH 5/7] forgot to end pod spec. --- SSZipArchive.podspec | 1 + 1 file changed, 1 insertion(+) diff --git a/SSZipArchive.podspec b/SSZipArchive.podspec index 4a0c3ac..b6d4e60 100644 --- a/SSZipArchive.podspec +++ b/SSZipArchive.podspec @@ -11,3 +11,4 @@ Pod::Spec.new do |s| s.preserve_paths = ['Tests', '.gitignore'] s.license = { :type => 'MIT', :file => 'LICENSE' } s.header_mappings_dir = '.' +end \ No newline at end of file From 74ce9fc2c73a1390b9abead3bbb4d0607cdbeac8 Mon Sep 17 00:00:00 2001 From: David Robles Date: Wed, 5 Nov 2014 15:34:55 -0800 Subject: [PATCH 6/7] Update Pod spec. --- SSZipArchive.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SSZipArchive.podspec b/SSZipArchive.podspec index b6d4e60..cb657a5 100644 --- a/SSZipArchive.podspec +++ b/SSZipArchive.podspec @@ -1,10 +1,10 @@ Pod::Spec.new do |s| s.name = 'SSZipArchive' - s.version = '0.2.3' + s.version = '0.2.2.1' s.summary = 'Utility class for zipping and unzipping files on iOS and Mac.' s.homepage = 'https://github.com/samsoffes/ssziparchive' s.author = { 'Sam Soffes' => 'sam@samsoff.es' } - s.source = { :git => 'https://github.com/samsoffes/ssziparchive.git', :tag => '0.2.2' } + s.source = { :git => 'https://github.com/samsoffes/ssziparchive.git', :tag => s.version.to_s } s.description = 'SSZipArchive is a simple utility class for zipping and unzipping files on iOS and Mac.' s.source_files = 'SSZipArchive.{h,m}', 'minizip/*.{h,c}' s.library = 'z' From 67403e8a283676787fcd07843aade0137452a04f Mon Sep 17 00:00:00 2001 From: David Robles Date: Wed, 5 Nov 2014 15:40:12 -0800 Subject: [PATCH 7/7] Update pod spec. --- SSZipArchive.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SSZipArchive.podspec b/SSZipArchive.podspec index cb657a5..15a55ac 100644 --- a/SSZipArchive.podspec +++ b/SSZipArchive.podspec @@ -4,7 +4,7 @@ Pod::Spec.new do |s| s.summary = 'Utility class for zipping and unzipping files on iOS and Mac.' s.homepage = 'https://github.com/samsoffes/ssziparchive' s.author = { 'Sam Soffes' => 'sam@samsoff.es' } - s.source = { :git => 'https://github.com/samsoffes/ssziparchive.git', :tag => s.version.to_s } + s.source = { :git => 'git@github.com:955dreams/ssziparchive.git', :tag => s.version.to_s } s.description = 'SSZipArchive is a simple utility class for zipping and unzipping files on iOS and Mac.' s.source_files = 'SSZipArchive.{h,m}', 'minizip/*.{h,c}' s.library = 'z'