Added tests to unzip & check zip files created with Mac OS X and Windows; updated README
This commit is contained in:
parent
f05b2ed31b
commit
c8f2e3843f
@ -42,10 +42,8 @@
|
||||
|
||||
- (IBAction) zipUnzip;
|
||||
- (IBAction) zipUnzip2;
|
||||
|
||||
- (void) test;
|
||||
- (void) test2;
|
||||
- (void) log:(NSString *)text;
|
||||
- (IBAction) zipCheck1;
|
||||
- (IBAction) zipCheck2;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -38,10 +38,31 @@
|
||||
#import "../Objective-Zip/ZipWriteStream.h"
|
||||
#import "../Objective-Zip/ZipReadStream.h"
|
||||
|
||||
#define HUGE_TEST_BLOCK_LENGTH (63000)
|
||||
#define HUGE_TEST_BLOCK_LENGTH (50000)
|
||||
#define HUGE_TEST_NUMBER_OF_BLOCKS (100000)
|
||||
|
||||
|
||||
@interface Objective_ZipViewController ()
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Tests
|
||||
|
||||
- (void) test1;
|
||||
- (void) test2;
|
||||
- (void) test3;
|
||||
- (void) test4;
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Logging
|
||||
|
||||
- (void) log:(NSString *)format, ...;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation Objective_ZipViewController
|
||||
|
||||
|
||||
@ -52,8 +73,8 @@
|
||||
}
|
||||
|
||||
- (void) dealloc {
|
||||
if (_testThread)
|
||||
[_testThread release];
|
||||
[_testThread release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@ -65,7 +86,7 @@
|
||||
if (_testThread)
|
||||
[_testThread release];
|
||||
|
||||
_testThread= [[NSThread alloc] initWithTarget:self selector:@selector(test) object:nil];
|
||||
_testThread= [[NSThread alloc] initWithTarget:self selector:@selector(test1) object:nil];
|
||||
[_testThread start];
|
||||
}
|
||||
|
||||
@ -77,67 +98,87 @@
|
||||
[_testThread start];
|
||||
}
|
||||
|
||||
- (void) test {
|
||||
- (IBAction) zipCheck1 {
|
||||
if (_testThread)
|
||||
[_testThread release];
|
||||
|
||||
_testThread= [[NSThread alloc] initWithTarget:self selector:@selector(test3) object:nil];
|
||||
[_testThread start];
|
||||
}
|
||||
|
||||
- (IBAction) zipCheck2 {
|
||||
if (_testThread)
|
||||
[_testThread release];
|
||||
|
||||
_testThread= [[NSThread alloc] initWithTarget:self selector:@selector(test4) object:nil];
|
||||
[_testThread start];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Test 1: zip & unzip
|
||||
|
||||
- (void) test1 {
|
||||
NSAutoreleasePool *pool= [[NSAutoreleasePool alloc] init];
|
||||
|
||||
@try {
|
||||
NSString *documentsDir= [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
|
||||
NSString *filePath= [documentsDir stringByAppendingPathComponent:@"test.zip"];
|
||||
NSString *documentsDir= [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
|
||||
NSString *filePath= [documentsDir stringByAppendingPathComponent:@"test.zip"];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: opening zip file for writing..." waitUntilDone:YES];
|
||||
@try {
|
||||
[[NSFileManager defaultManager] removeItemAtPath:filePath error:NULL];
|
||||
|
||||
[self log:@"Test 1: opening zip file for writing..."];
|
||||
|
||||
ZipFile *zipFile= [[ZipFile alloc] initWithFileName:filePath mode:ZipFileModeCreate];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: adding first file..." waitUntilDone:YES];
|
||||
[self log:@"Test 1: adding first file..."];
|
||||
|
||||
ZipWriteStream *stream1= [zipFile writeFileInZipWithName:@"abc.txt" fileDate:[NSDate dateWithTimeIntervalSinceNow:-86400.0] compressionLevel:ZipCompressionLevelBest];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: writing to first file's stream..." waitUntilDone:YES];
|
||||
[self log:@"Test 1: writing to first file's stream..."];
|
||||
|
||||
NSString *text= @"abc";
|
||||
[stream1 writeData:[text dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: closing first file's stream..." waitUntilDone:YES];
|
||||
[self log:@"Test 1: closing first file's stream..."];
|
||||
|
||||
[stream1 finishedWriting];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: adding second file..." waitUntilDone:YES];
|
||||
[self log:@"Test 1: adding second file..."];
|
||||
|
||||
NSString *file2name= @"x/y/z/xyz.txt";
|
||||
ZipWriteStream *stream2= [zipFile writeFileInZipWithName:file2name compressionLevel:ZipCompressionLevelNone];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: writing to second file's stream..." waitUntilDone:YES];
|
||||
[self log:@"Test 1: writing to second file's stream..."];
|
||||
|
||||
NSString *text2= @"XYZ";
|
||||
[stream2 writeData:[text2 dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: closing second file's stream..." waitUntilDone:YES];
|
||||
[self log:@"Test 1: closing second file's stream..."];
|
||||
|
||||
[stream2 finishedWriting];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: closing zip file..." waitUntilDone:YES];
|
||||
[self log:@"Test 1: closing zip file..."];
|
||||
|
||||
[zipFile close];
|
||||
[zipFile release];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: opening zip file for reading..." waitUntilDone:YES];
|
||||
[self log:@"Test 1: opening zip file for reading..."];
|
||||
|
||||
ZipFile *unzipFile= [[ZipFile alloc] initWithFileName:filePath mode:ZipFileModeUnzip];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: reading file infos..." waitUntilDone:YES];
|
||||
[self log:@"Test 1: reading file infos..."];
|
||||
|
||||
NSArray *infos= [unzipFile listFileInZipInfos];
|
||||
for (FileInZipInfo *info in infos) {
|
||||
NSString *fileInfo= [NSString stringWithFormat:@"Test 1: - %@ %@ %d (%d)", info.name, info.date, info.size, info.level];
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:fileInfo waitUntilDone:YES];
|
||||
}
|
||||
for (FileInZipInfo *info in infos)
|
||||
[self log:@"Test 1: - %@ %@ %d (%d)", info.name, info.date, info.size, info.level];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: opening first file..." waitUntilDone:YES];
|
||||
[self log:@"Test 1: opening first file..."];
|
||||
|
||||
[unzipFile goToFirstFileInZip];
|
||||
ZipReadStream *read1= [unzipFile readCurrentFileInZip];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: reading from first file's stream..." waitUntilDone:YES];
|
||||
[self log:@"Test 1: reading from first file's stream..."];
|
||||
|
||||
NSMutableData *data1= [[[NSMutableData alloc] initWithLength:256] autorelease];
|
||||
int bytesRead1= [read1 readDataWithBuffer:data1];
|
||||
@ -150,20 +191,20 @@
|
||||
}
|
||||
|
||||
if (ok)
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: content of first file is OK" waitUntilDone:YES];
|
||||
[self log:@"Test 1: content of first file is OK"];
|
||||
else
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: content of first file is WRONG" waitUntilDone:YES];
|
||||
[self log:@"Test 1: content of first file is WRONG"];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: closing first file's stream..." waitUntilDone:YES];
|
||||
[self log:@"Test 1: closing first file's stream..."];
|
||||
|
||||
[read1 finishedReading];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: opening second file..." waitUntilDone:YES];
|
||||
[self log:@"Test 1: opening second file..."];
|
||||
|
||||
[unzipFile locateFileInZip:file2name];
|
||||
ZipReadStream *read2= [unzipFile readCurrentFileInZip];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: reading from second file's stream..." waitUntilDone:YES];
|
||||
[self log:@"Test 1: reading from second file's stream..."];
|
||||
|
||||
NSMutableData *data2= [[[NSMutableData alloc] initWithLength:256] autorelease];
|
||||
int bytesRead2= [read2 readDataWithBuffer:data2];
|
||||
@ -176,53 +217,60 @@
|
||||
}
|
||||
|
||||
if (ok)
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: content of second file is OK" waitUntilDone:YES];
|
||||
[self log:@"Test 1: content of second file is OK"];
|
||||
else
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: content of second file is WRONG" waitUntilDone:YES];
|
||||
[self log:@"Test 1: content of second file is WRONG"];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: closing second file's stream..." waitUntilDone:YES];
|
||||
[self log:@"Test 1: closing second file's stream..."];
|
||||
|
||||
[read2 finishedReading];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: closing zip file..." waitUntilDone:YES];
|
||||
[self log:@"Test 1: closing zip file..."];
|
||||
|
||||
[unzipFile close];
|
||||
[unzipFile release];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: test terminated succesfully" waitUntilDone:YES];
|
||||
[self log:@"Test 1: test terminated succesfully"];
|
||||
|
||||
} @catch (ZipException *ze) {
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: caught a ZipException (see logs), terminating..." waitUntilDone:YES];
|
||||
[self log:@"Test 1: caught a ZipException (see logs), terminating..."];
|
||||
|
||||
NSLog(@"Test 1: ZipException caught: %d - %@", ze.error, [ze reason]);
|
||||
|
||||
} @catch (id e) {
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 1: caught a generic exception (see logs), terminating..." waitUntilDone:YES];
|
||||
[self log:@"Test 1: caught a generic exception (see logs), terminating..."];
|
||||
|
||||
NSLog(@"Test 1: Exception caught: %@ - %@", [[e class] description], [e description]);
|
||||
|
||||
} @finally {
|
||||
[[NSFileManager defaultManager] removeItemAtPath:filePath error:NULL];
|
||||
}
|
||||
|
||||
[pool drain];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Test 2: zip & unzip 5 GB
|
||||
|
||||
- (void) test2 {
|
||||
NSAutoreleasePool *pool= [[NSAutoreleasePool alloc] init];
|
||||
|
||||
NSString *documentsDir= [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
|
||||
NSString *filePath= [documentsDir stringByAppendingPathComponent:@"huge_test.zip"];
|
||||
|
||||
@try {
|
||||
NSString *documentsDir= [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
|
||||
NSString *filePath= [documentsDir stringByAppendingPathComponent:@"huge_test.zip"];
|
||||
|
||||
[[NSFileManager defaultManager] removeItemAtPath:filePath error:NULL];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 2: opening zip file for writing..." waitUntilDone:YES];
|
||||
[self log:@"Test 2: opening zip file for writing..."];
|
||||
|
||||
ZipFile *zipFile= [[ZipFile alloc] initWithFileName:filePath mode:ZipFileModeCreate];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 2: adding file..." waitUntilDone:YES];
|
||||
[self log:@"Test 2: adding file..."];
|
||||
|
||||
ZipWriteStream *stream= [zipFile writeFileInZipWithName:@"huge_file.txt" compressionLevel:ZipCompressionLevelBest];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 2: writing to file's stream..." waitUntilDone:YES];
|
||||
[self log:@"Test 2: writing to file's stream..."];
|
||||
|
||||
NSMutableData *data= [[NSMutableData alloc] initWithLength:HUGE_TEST_BLOCK_LENGTH];
|
||||
SecRandomCopyBytes(kSecRandomDefault, [data length], [data mutableBytes]);
|
||||
@ -234,32 +282,29 @@
|
||||
for (int i= 0; i < HUGE_TEST_NUMBER_OF_BLOCKS; i++) {
|
||||
[stream writeData:data];
|
||||
|
||||
if (i % 100 == 0) {
|
||||
NSString *logLine= [[NSString alloc] initWithFormat:@"Test 2: written %d KB...", ([data length] / 1024) * (i +1)];
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:logLine waitUntilDone:YES];
|
||||
[logLine release];
|
||||
}
|
||||
if (i % 100 == 0)
|
||||
[self log:@"Test 2: written %d KB...", ([data length] / 1024) * (i +1)];
|
||||
}
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 2: closing file's stream..." waitUntilDone:YES];
|
||||
[self log:@"Test 2: closing file's stream..."];
|
||||
|
||||
[stream finishedWriting];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 2: closing zip file..." waitUntilDone:YES];
|
||||
[self log:@"Test 2: closing zip file..."];
|
||||
|
||||
[zipFile close];
|
||||
[zipFile release];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 2: opening zip file for reading..." waitUntilDone:YES];
|
||||
[self log:@"Test 2: opening zip file for reading..."];
|
||||
|
||||
ZipFile *unzipFile= [[ZipFile alloc] initWithFileName:filePath mode:ZipFileModeUnzip];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 2: opening file..." waitUntilDone:YES];
|
||||
[self log:@"Test 2: opening file..."];
|
||||
|
||||
[unzipFile goToFirstFileInZip];
|
||||
ZipReadStream *read= [unzipFile readCurrentFileInZip];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 2: reading from file's stream..." waitUntilDone:YES];
|
||||
[self log:@"Test 2: reading from file's stream..."];
|
||||
|
||||
for (int i= 0; i < HUGE_TEST_NUMBER_OF_BLOCKS; i++) {
|
||||
int bytesRead= [read readDataWithBuffer:buffer];
|
||||
@ -271,55 +316,182 @@
|
||||
ok= YES;
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
NSString *logLine= [[NSString alloc] initWithFormat:@"Test 2: content of file is WRONG at position %d KB", ([buffer length] / 1024) * i];
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:logLine waitUntilDone:YES];
|
||||
[logLine release];
|
||||
}
|
||||
if (!ok)
|
||||
[self log:@"Test 2: content of file is WRONG at position %d KB", ([buffer length] / 1024) * i];
|
||||
|
||||
if (i % 100 == 0) {
|
||||
NSString *logLine= [[NSString alloc] initWithFormat:@"Test 2: read %d KB...", ([buffer length] / 1024) * (i +1)];
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:logLine waitUntilDone:YES];
|
||||
[logLine release];
|
||||
}
|
||||
if (i % 100 == 0)
|
||||
[self log:@"Test 2: read %d KB...", ([buffer length] / 1024) * (i +1)];
|
||||
}
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 2: closing file's stream..." waitUntilDone:YES];
|
||||
[self log:@"Test 2: closing file's stream..."];
|
||||
|
||||
[read finishedReading];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 2: closing zip file..." waitUntilDone:YES];
|
||||
[self log:@"Test 2: closing zip file..."];
|
||||
|
||||
[unzipFile close];
|
||||
[unzipFile release];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 2: deleting zip file..." waitUntilDone:YES];
|
||||
|
||||
[[NSFileManager defaultManager] removeItemAtPath:filePath error:NULL];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 2: test terminated succesfully" waitUntilDone:YES];
|
||||
[self log:@"Test 2: test terminated succesfully"];
|
||||
|
||||
[data release];
|
||||
[buffer release];
|
||||
|
||||
} @catch (ZipException *ze) {
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 2: caught a ZipException (see logs), terminating..." waitUntilDone:YES];
|
||||
[self log:@"Test 2: caught a ZipException (see logs), terminating..."];
|
||||
|
||||
NSLog(@"Test 2: ZipException caught: %d - %@", ze.error, [ze reason]);
|
||||
|
||||
} @catch (id e) {
|
||||
[self performSelectorOnMainThread:@selector(log:) withObject:@"Test 2: caught a generic exception (see logs), terminating..." waitUntilDone:YES];
|
||||
[self log:@"Test 2: caught a generic exception (see logs), terminating..."];
|
||||
|
||||
NSLog(@"Test 2: Exception caught: %@ - %@", [[e class] description], [e description]);
|
||||
|
||||
} @finally {
|
||||
[[NSFileManager defaultManager] removeItemAtPath:filePath error:NULL];
|
||||
}
|
||||
|
||||
[pool drain];
|
||||
}
|
||||
|
||||
- (void) log:(NSString *)text {
|
||||
NSLog(@"%@", text);
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Test 3: unzip & check Mac zip file
|
||||
|
||||
- (void) test3 {
|
||||
NSAutoreleasePool *pool= [[NSAutoreleasePool alloc] init];
|
||||
|
||||
_textView.text= [_textView.text stringByAppendingString:text];
|
||||
NSString *filePath= [[NSBundle mainBundle] pathForResource:@"mac_test_file" ofType:@"zip"];
|
||||
|
||||
@try {
|
||||
[self log:@"Test 3: opening zip file for reading..."];
|
||||
|
||||
ZipFile *unzipFile= [[ZipFile alloc] initWithFileName:filePath mode:ZipFileModeUnzip];
|
||||
|
||||
[self log:@"Test 3: opening file..."];
|
||||
|
||||
[unzipFile goToFirstFileInZip];
|
||||
ZipReadStream *read= [unzipFile readCurrentFileInZip];
|
||||
|
||||
[self log:@"Test 3: reading from file's stream..."];
|
||||
|
||||
NSMutableData *buffer= [[NSMutableData alloc] initWithLength:1024];
|
||||
|
||||
int bytesRead= [read readDataWithBuffer:buffer];
|
||||
|
||||
NSString *fileText= [[[NSString alloc] initWithBytes:[buffer bytes] length:bytesRead encoding:NSUTF8StringEncoding] autorelease];
|
||||
if ([fileText isEqualToString:@"Objective-Zip Mac test file\n"])
|
||||
[self log:@"Test 3: content of Mac file is OK"];
|
||||
else
|
||||
[self log:@"Test 3: content of Mac file is WRONG"];
|
||||
|
||||
[self log:@"Test 3: closing file's stream..."];
|
||||
|
||||
[read finishedReading];
|
||||
|
||||
[self log:@"Test 3: closing zip file..."];
|
||||
|
||||
[unzipFile close];
|
||||
[unzipFile release];
|
||||
|
||||
[self log:@"Test 3: test terminated succesfully"];
|
||||
|
||||
[buffer release];
|
||||
|
||||
} @catch (ZipException *ze) {
|
||||
[self log:@"Test 3: caught a ZipException (see logs), terminating..."];
|
||||
|
||||
NSLog(@"Test 3: ZipException caught: %d - %@", ze.error, [ze reason]);
|
||||
|
||||
} @catch (id e) {
|
||||
[self log:@"Test 3: caught a generic exception (see logs), terminating..."];
|
||||
|
||||
NSLog(@"Test 3: Exception caught: %@ - %@", [[e class] description], [e description]);
|
||||
|
||||
}
|
||||
|
||||
[pool drain];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Test 4: unzip & check Win zip file
|
||||
|
||||
- (void) test4 {
|
||||
NSAutoreleasePool *pool= [[NSAutoreleasePool alloc] init];
|
||||
|
||||
NSString *filePath= [[NSBundle mainBundle] pathForResource:@"win_test_file" ofType:@"zip"];
|
||||
|
||||
@try {
|
||||
[self log:@"Test 4: opening zip file for reading..."];
|
||||
|
||||
ZipFile *unzipFile= [[ZipFile alloc] initWithFileName:filePath mode:ZipFileModeUnzip];
|
||||
|
||||
[self log:@"Test 4: opening file..."];
|
||||
|
||||
[unzipFile goToFirstFileInZip];
|
||||
ZipReadStream *read= [unzipFile readCurrentFileInZip];
|
||||
|
||||
[self log:@"Test 4: reading from file's stream..."];
|
||||
|
||||
NSMutableData *buffer= [[NSMutableData alloc] initWithLength:1024];
|
||||
|
||||
int bytesRead= [read readDataWithBuffer:buffer];
|
||||
|
||||
NSString *fileText= [[[NSString alloc] initWithBytes:[buffer bytes] length:bytesRead encoding:NSUTF8StringEncoding] autorelease];
|
||||
if ([fileText isEqualToString:@"Objective-Zip Windows test file\r\n"])
|
||||
[self log:@"Test 4: content of Win file is OK"];
|
||||
else
|
||||
[self log:@"Test 4: content of Win file is WRONG"];
|
||||
|
||||
[self log:@"Test 4: closing file's stream..."];
|
||||
|
||||
[read finishedReading];
|
||||
|
||||
[self log:@"Test 4: closing zip file..."];
|
||||
|
||||
[unzipFile close];
|
||||
[unzipFile release];
|
||||
|
||||
[self log:@"Test 4: test terminated succesfully"];
|
||||
|
||||
[buffer release];
|
||||
|
||||
} @catch (ZipException *ze) {
|
||||
[self log:@"Test 4: caught a ZipException (see logs), terminating..."];
|
||||
|
||||
NSLog(@"Test 4: ZipException caught: %d - %@", ze.error, [ze reason]);
|
||||
|
||||
} @catch (id e) {
|
||||
[self log:@"Test 4: caught a generic exception (see logs), terminating..."];
|
||||
|
||||
NSLog(@"Test 4: Exception caught: %@ - %@", [[e class] description], [e description]);
|
||||
}
|
||||
|
||||
[pool drain];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Logging
|
||||
|
||||
- (void) log:(NSString *)format, ... {
|
||||
|
||||
// Variable arguments formatting
|
||||
va_list arguments;
|
||||
va_start(arguments, format);
|
||||
NSString *logLine= [[NSString alloc] initWithFormat:format arguments:arguments];
|
||||
va_end(arguments);
|
||||
|
||||
[self performSelectorOnMainThread:@selector(printLog:) withObject:logLine waitUntilDone:YES];
|
||||
|
||||
[logLine release];
|
||||
}
|
||||
|
||||
- (void) printLog:(NSString *)logLine {
|
||||
NSLog(@"%@", logLine);
|
||||
|
||||
_textView.text= [_textView.text stringByAppendingString:logLine];
|
||||
_textView.text= [_textView.text stringByAppendingString:@"\n"];
|
||||
|
||||
NSRange range;
|
||||
@ -328,4 +500,5 @@
|
||||
[_textView scrollRangeToVisible:range];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
@ -43,6 +43,8 @@
|
||||
8CD8B40F17766067005212EC /* trees.c in Sources */ = {isa = PBXBuildFile; fileRef = 8CD8B3FC17766067005212EC /* trees.c */; };
|
||||
8CD8B41017766067005212EC /* uncompr.c in Sources */ = {isa = PBXBuildFile; fileRef = 8CD8B3FE17766067005212EC /* uncompr.c */; };
|
||||
8CD8B41117766067005212EC /* zutil.c in Sources */ = {isa = PBXBuildFile; fileRef = 8CD8B40117766067005212EC /* zutil.c */; };
|
||||
8CE370031777427E0082BEE9 /* mac_test_file.zip in Resources */ = {isa = PBXBuildFile; fileRef = 8CE370011777427E0082BEE9 /* mac_test_file.zip */; };
|
||||
8CE370041777427E0082BEE9 /* win_test_file.zip in Resources */ = {isa = PBXBuildFile; fileRef = 8CE370021777427E0082BEE9 /* win_test_file.zip */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@ -107,6 +109,8 @@
|
||||
8CD8B40017766067005212EC /* zlib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = zlib.h; path = ZLib/zlib.h; sourceTree = "<group>"; };
|
||||
8CD8B40117766067005212EC /* zutil.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = zutil.c; path = ZLib/zutil.c; sourceTree = "<group>"; };
|
||||
8CD8B40217766067005212EC /* zutil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = zutil.h; path = ZLib/zutil.h; sourceTree = "<group>"; };
|
||||
8CE370011777427E0082BEE9 /* mac_test_file.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = mac_test_file.zip; sourceTree = "<group>"; };
|
||||
8CE370021777427E0082BEE9 /* win_test_file.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = win_test_file.zip; sourceTree = "<group>"; };
|
||||
8D1107310486CEB800E47090 /* Objective_Zip-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Objective_Zip-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
@ -174,6 +178,8 @@
|
||||
29B97317FDCFA39411CA2CEA /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8CE370011777427E0082BEE9 /* mac_test_file.zip */,
|
||||
8CE370021777427E0082BEE9 /* win_test_file.zip */,
|
||||
8C8F2D9210EBCE0300F75833 /* ObjectiveZipIcon.png */,
|
||||
8C8F2D3910EBC94B00F75833 /* Default.png */,
|
||||
2899E5210DE3E06400AC0155 /* Objective_ZipViewController.xib */,
|
||||
@ -325,6 +331,8 @@
|
||||
8C8F2D9310EBCE0300F75833 /* ObjectiveZipIcon.png in Resources */,
|
||||
8C1D598D1771057D006D69C3 /* GETTING_STARTED.md in Resources */,
|
||||
8C1D598E1771057D006D69C3 /* README.md in Resources */,
|
||||
8CE370031777427E0082BEE9 /* mac_test_file.zip in Resources */,
|
||||
8CE370041777427E0082BEE9 /* win_test_file.zip in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -102,6 +102,52 @@
|
||||
<string key="NSFrame">{{20, 64}, {280, 37}}</string>
|
||||
<reference key="NSSuperview" ref="774585933"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="1005186811"/>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<int key="IBUIContentHorizontalAlignment">0</int>
|
||||
<int key="IBUIContentVerticalAlignment">0</int>
|
||||
<int key="IBUIButtonType">1</int>
|
||||
<string key="IBUINormalTitle">5 GB Zip & Unzip (use with caution)</string>
|
||||
<reference key="IBUIHighlightedTitleColor" ref="884333554"/>
|
||||
<object class="NSColor" key="IBUINormalTitleColor">
|
||||
<int key="NSColorSpace">1</int>
|
||||
<bytes key="NSRGB">MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA</bytes>
|
||||
</object>
|
||||
<reference key="IBUINormalTitleShadowColor" ref="114389561"/>
|
||||
<reference key="IBUIFontDescription" ref="975473552"/>
|
||||
<reference key="IBUIFont" ref="64712977"/>
|
||||
</object>
|
||||
<object class="IBUIButton" id="1005186811">
|
||||
<reference key="NSNextResponder" ref="774585933"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{20, 108}, {280, 37}}</string>
|
||||
<reference key="NSSuperview" ref="774585933"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="68194376"/>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<int key="IBUIContentHorizontalAlignment">0</int>
|
||||
<int key="IBUIContentVerticalAlignment">0</int>
|
||||
<int key="IBUIButtonType">1</int>
|
||||
<string key="IBUINormalTitle">Unzip & Check Mac OS X Zip File</string>
|
||||
<reference key="IBUIHighlightedTitleColor" ref="884333554"/>
|
||||
<object class="NSColor" key="IBUINormalTitleColor">
|
||||
<int key="NSColorSpace">1</int>
|
||||
<bytes key="NSRGB">MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA</bytes>
|
||||
</object>
|
||||
<reference key="IBUINormalTitleShadowColor" ref="114389561"/>
|
||||
<reference key="IBUIFontDescription" ref="975473552"/>
|
||||
<reference key="IBUIFont" ref="64712977"/>
|
||||
</object>
|
||||
<object class="IBUIButton" id="68194376">
|
||||
<reference key="NSNextResponder" ref="774585933"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{20, 152}, {280, 37}}</string>
|
||||
<reference key="NSSuperview" ref="774585933"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="261814878"/>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
|
||||
@ -109,7 +155,7 @@
|
||||
<int key="IBUIContentHorizontalAlignment">0</int>
|
||||
<int key="IBUIContentVerticalAlignment">0</int>
|
||||
<int key="IBUIButtonType">1</int>
|
||||
<string key="IBUINormalTitle">6.3 GB Zip & Unzip (use with caution)</string>
|
||||
<string key="IBUINormalTitle">Unzip & Check Windows Zip File</string>
|
||||
<reference key="IBUIHighlightedTitleColor" ref="884333554"/>
|
||||
<object class="NSColor" key="IBUINormalTitleColor">
|
||||
<int key="NSColorSpace">1</int>
|
||||
@ -122,7 +168,7 @@
|
||||
<object class="IBUIView" id="261814878">
|
||||
<reference key="NSNextResponder" ref="774585933"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{20, 108}, {280, 332}}</string>
|
||||
<string key="NSFrame">{{20, 196}, {280, 244}}</string>
|
||||
<reference key="NSSuperview" ref="774585933"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="718446055"/>
|
||||
@ -137,10 +183,9 @@
|
||||
<object class="IBUITextView" id="718446055">
|
||||
<reference key="NSNextResponder" ref="774585933"/>
|
||||
<int key="NSvFlags">274</int>
|
||||
<string key="NSFrame">{{20, 108}, {280, 332}}</string>
|
||||
<string key="NSFrame">{{20, 196}, {280, 244}}</string>
|
||||
<reference key="NSSuperview" ref="774585933"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<bool key="IBUIClipsSubviews">YES</bool>
|
||||
<bool key="IBUIMultipleTouchEnabled">YES</bool>
|
||||
@ -219,6 +264,24 @@
|
||||
</object>
|
||||
<int key="connectionID">17</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchEventConnection" key="connection">
|
||||
<string key="label">zipCheck1</string>
|
||||
<reference key="source" ref="1005186811"/>
|
||||
<reference key="destination" ref="372490531"/>
|
||||
<int key="IBEventType">7</int>
|
||||
</object>
|
||||
<int key="connectionID">22</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchEventConnection" key="connection">
|
||||
<string key="label">zipCheck2</string>
|
||||
<reference key="source" ref="68194376"/>
|
||||
<reference key="destination" ref="372490531"/>
|
||||
<int key="IBEventType">7</int>
|
||||
</object>
|
||||
<int key="connectionID">23</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
@ -252,6 +315,8 @@
|
||||
<reference ref="718446055"/>
|
||||
<reference ref="296619241"/>
|
||||
<reference ref="690801101"/>
|
||||
<reference ref="1005186811"/>
|
||||
<reference ref="68194376"/>
|
||||
</object>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
@ -283,6 +348,16 @@
|
||||
<reference key="object" ref="690801101"/>
|
||||
<reference key="parent" ref="774585933"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">18</int>
|
||||
<reference key="object" ref="1005186811"/>
|
||||
<reference key="parent" ref="774585933"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">19</int>
|
||||
<reference key="object" ref="68194376"/>
|
||||
<reference key="parent" ref="774585933"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="flattenedProperties">
|
||||
@ -296,6 +371,8 @@
|
||||
<string>10.IBPluginDependency</string>
|
||||
<string>13.IBPluginDependency</string>
|
||||
<string>15.IBPluginDependency</string>
|
||||
<string>18.IBPluginDependency</string>
|
||||
<string>19.IBPluginDependency</string>
|
||||
<string>6.IBPluginDependency</string>
|
||||
<string>8.IBPluginDependency</string>
|
||||
<string>9.IBPluginDependency</string>
|
||||
@ -312,6 +389,8 @@
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="unlocalizedProperties">
|
||||
@ -326,7 +405,7 @@
|
||||
<reference key="dict.values" ref="0"/>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">17</int>
|
||||
<int key="maxID">23</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
@ -338,6 +417,8 @@
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>zipCheck1</string>
|
||||
<string>zipCheck2</string>
|
||||
<string>zipUnzip</string>
|
||||
<string>zipUnzip2</string>
|
||||
</object>
|
||||
@ -345,17 +426,29 @@
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>id</string>
|
||||
<string>id</string>
|
||||
<string>id</string>
|
||||
<string>id</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="actionInfosByName">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>zipCheck1</string>
|
||||
<string>zipCheck2</string>
|
||||
<string>zipUnzip</string>
|
||||
<string>zipUnzip2</string>
|
||||
</object>
|
||||
<object class="NSArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBActionInfo">
|
||||
<string key="name">zipCheck1</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo">
|
||||
<string key="name">zipCheck2</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo">
|
||||
<string key="name">zipUnzip</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
|
@ -47,7 +47,8 @@ Version history
|
||||
Version 0.8.3:
|
||||
|
||||
- Finally used correctly the 64 bit APIs. Thanks to Nathan Moinvaziri for advicing.
|
||||
- Updated test code to zip & unzip up to 6.3 GB.
|
||||
- Updated test code to zip & unzip up to 5 GB.
|
||||
- Added tests with unzip & check of zip files create with Mac OS X 10.8 and Windows 7.
|
||||
|
||||
Version 0.8.2:
|
||||
|
||||
|
BIN
mac_test_file.zip
Normal file
BIN
mac_test_file.zip
Normal file
Binary file not shown.
BIN
win_test_file.zip
Normal file
BIN
win_test_file.zip
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user