Introduced method variants with NSError handling; simplified exception creation
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
- (IBAction) zipUnzip2;
|
||||
- (IBAction) zipCheck1;
|
||||
- (IBAction) zipCheck2;
|
||||
- (IBAction) errorWrapping;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
- (void) test2;
|
||||
- (void) test3;
|
||||
- (void) test4;
|
||||
- (void) test5;
|
||||
|
||||
|
||||
#pragma mark -
|
||||
@@ -97,6 +98,12 @@
|
||||
[_testThread start];
|
||||
}
|
||||
|
||||
- (IBAction) errorWrapping {
|
||||
|
||||
_testThread= [[NSThread alloc] initWithTarget:self selector:@selector(test5) object:nil];
|
||||
[_testThread start];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Test 1: zip & unzip
|
||||
@@ -156,14 +163,14 @@
|
||||
[self log:@"Test 1: - %@ %@ %d (%d)", info.name, info.date, info.size, info.level];
|
||||
|
||||
[self log:@"Test 1: opening first file..."];
|
||||
|
||||
[unzipFile goToFirstFileInZip];
|
||||
|
||||
[unzipFile goToFirstFileInZip];
|
||||
OZZipReadStream *read1= [unzipFile readCurrentFileInZip];
|
||||
|
||||
[self log:@"Test 1: reading from first file's stream..."];
|
||||
|
||||
NSMutableData *data1= [[NSMutableData alloc] initWithLength:256];
|
||||
int bytesRead1= [read1 readDataWithBuffer:data1];
|
||||
NSUInteger bytesRead1= [read1 readDataWithBuffer:data1];
|
||||
|
||||
BOOL ok= NO;
|
||||
if (bytesRead1 == 3) {
|
||||
@@ -189,7 +196,7 @@
|
||||
[self log:@"Test 1: reading from second file's stream..."];
|
||||
|
||||
NSMutableData *data2= [[NSMutableData alloc] initWithLength:256];
|
||||
int bytesRead2= [read2 readDataWithBuffer:data2];
|
||||
NSUInteger bytesRead2= [read2 readDataWithBuffer:data2];
|
||||
|
||||
ok= NO;
|
||||
if (bytesRead2 == 3) {
|
||||
@@ -216,7 +223,7 @@
|
||||
} @catch (OZZipException *ze) {
|
||||
[self log:@"Test 1: caught a ZipException (see logs), terminating..."];
|
||||
|
||||
NSLog(@"Test 1: ZipException caught: %d - %@", ze.error, [ze reason]);
|
||||
NSLog(@"Test 1: ZipException caught: %ld - %@", (long) ze.error, [ze reason]);
|
||||
|
||||
} @catch (id e) {
|
||||
[self log:@"Test 1: caught a generic exception (see logs), terminating..."];
|
||||
@@ -286,7 +293,7 @@
|
||||
[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];
|
||||
NSUInteger bytesRead= [read readDataWithBuffer:buffer];
|
||||
|
||||
BOOL ok= NO;
|
||||
if (bytesRead == [data length]) {
|
||||
@@ -315,7 +322,7 @@
|
||||
} @catch (OZZipException *ze) {
|
||||
[self log:@"Test 2: caught a ZipException (see logs), terminating..."];
|
||||
|
||||
NSLog(@"Test 2: ZipException caught: %d - %@", ze.error, [ze reason]);
|
||||
NSLog(@"Test 2: ZipException caught: %ld - %@", (long) ze.error, [ze reason]);
|
||||
|
||||
} @catch (id e) {
|
||||
[self log:@"Test 2: caught a generic exception (see logs), terminating..."];
|
||||
@@ -352,7 +359,7 @@
|
||||
|
||||
NSMutableData *buffer= [[NSMutableData alloc] initWithLength:1024];
|
||||
|
||||
int bytesRead= [read readDataWithBuffer:buffer];
|
||||
NSUInteger bytesRead= [read readDataWithBuffer:buffer];
|
||||
|
||||
NSString *fileText= [[NSString alloc] initWithBytes:[buffer bytes] length:bytesRead encoding:NSUTF8StringEncoding];
|
||||
if ([fileText isEqualToString:@"Objective-Zip Mac test file\n"])
|
||||
@@ -373,7 +380,7 @@
|
||||
} @catch (OZZipException *ze) {
|
||||
[self log:@"Test 3: caught a ZipException (see logs), terminating..."];
|
||||
|
||||
NSLog(@"Test 3: ZipException caught: %d - %@", ze.error, [ze reason]);
|
||||
NSLog(@"Test 3: ZipException caught: %ld - %@", (long) ze.error, [ze reason]);
|
||||
|
||||
} @catch (id e) {
|
||||
[self log:@"Test 3: caught a generic exception (see logs), terminating..."];
|
||||
@@ -406,7 +413,7 @@
|
||||
|
||||
NSMutableData *buffer= [[NSMutableData alloc] initWithLength:1024];
|
||||
|
||||
int bytesRead= [read readDataWithBuffer:buffer];
|
||||
NSUInteger bytesRead= [read readDataWithBuffer:buffer];
|
||||
|
||||
NSString *fileText= [[NSString alloc] initWithBytes:[buffer bytes] length:bytesRead encoding:NSUTF8StringEncoding];
|
||||
if ([fileText isEqualToString:@"Objective-Zip Windows test file\r\n"])
|
||||
@@ -427,7 +434,7 @@
|
||||
} @catch (OZZipException *ze) {
|
||||
[self log:@"Test 4: caught a ZipException (see logs), terminating..."];
|
||||
|
||||
NSLog(@"Test 4: ZipException caught: %d - %@", ze.error, [ze reason]);
|
||||
NSLog(@"Test 4: ZipException caught: %ld - %@", (long) ze.error, [ze reason]);
|
||||
|
||||
} @catch (id e) {
|
||||
[self log:@"Test 4: caught a generic exception (see logs), terminating..."];
|
||||
@@ -437,6 +444,66 @@
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Test 5: error wrapping
|
||||
|
||||
- (void) test5 {
|
||||
@autoreleasepool {
|
||||
|
||||
NSString *filePath= @"/root.zip";
|
||||
|
||||
@try {
|
||||
[self log:@"Test 5: opening impossible zip file for writing..."];
|
||||
|
||||
OZZipFile *zipFile= [[OZZipFile alloc] initWithFileName:filePath mode:OZZipFileModeCreate];
|
||||
|
||||
[self log:@"Test 5: test failed, no error reported"];
|
||||
|
||||
[zipFile close];
|
||||
|
||||
} @catch (OZZipException *ze) {
|
||||
if (ze.error != ERROR_NO_SUCH_FILE) {
|
||||
[self log:@"Test 5: test failed, wrong error reported"];
|
||||
|
||||
} else {
|
||||
[self log:@"Test 5: correct error reported"];
|
||||
}
|
||||
|
||||
} @catch (id e) {
|
||||
[self log:@"Test 5: caught a generic exception (see logs)"];
|
||||
|
||||
NSLog(@"Test 5: Exception caught: %@ - %@", [[e class] description], [e description]);
|
||||
}
|
||||
|
||||
@try {
|
||||
[self log:@"Test 5: opening again impossible zip file for writing..."];
|
||||
|
||||
NSError *error= nil;
|
||||
OZZipFile *zipFile= [[OZZipFile alloc] initWithFileName:filePath mode:OZZipFileModeCreate error:&error];
|
||||
|
||||
if (zipFile || (!error)) {
|
||||
[self log:@"Test 5: test failed, no error reported"];
|
||||
|
||||
[zipFile close];
|
||||
|
||||
} else {
|
||||
if (error.code != ERROR_NO_SUCH_FILE) {
|
||||
[self log:@"Test 5: test failed, wrong error reported"];
|
||||
|
||||
} else {
|
||||
[self log:@"Test 5: correct error reported"];
|
||||
[self log:@"Test 5: test terminated succesfully"];
|
||||
}
|
||||
}
|
||||
|
||||
} @catch (id e) {
|
||||
[self log:@"Test 5: caught a generic exception (see logs), terminating..."];
|
||||
|
||||
NSLog(@"Test 5: Exception caught: %@ - %@", [[e class] description], [e description]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Logging
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
@interface OZFileInZipInfo : NSObject
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Properties
|
||||
|
||||
|
||||
@@ -33,12 +33,34 @@
|
||||
|
||||
#import "OZZipException.h"
|
||||
|
||||
#define ERROR_WRAP_BEGIN \
|
||||
@try {
|
||||
|
||||
#define ERROR_WRAP_END(err) \
|
||||
} @catch (OZZipException *ze) { \
|
||||
if (ze.error) { \
|
||||
if (err) { \
|
||||
*err= [NSError errorWithDomain:@"ObjectiveZipErrorDomain" \
|
||||
code:ze.error \
|
||||
userInfo:@{NSLocalizedDescriptionKey: ze.name, \
|
||||
NSLocalizedFailureReasonErrorKey: ze.reason}]; \
|
||||
} \
|
||||
} else \
|
||||
@throw ze; \
|
||||
} @catch (NSException *exc) { \
|
||||
@throw exc; \
|
||||
}
|
||||
|
||||
|
||||
@interface OZZipException (Internals)
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Initialization
|
||||
|
||||
+ (OZZipException *) zipExceptionWithReason:(NSString *)format, ...;
|
||||
+ (OZZipException *) zipExceptionWithError:(NSInteger)error reason:(NSString *)format, ...;
|
||||
|
||||
- (instancetype) initWithReason:(NSString *)reason;
|
||||
- (instancetype) initWithError:(NSInteger)error reason:(NSString *)reason;
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#define ERROR_NO_SUCH_FILE (-9001)
|
||||
|
||||
|
||||
@interface OZZipException : NSException
|
||||
|
||||
|
||||
@@ -56,6 +56,28 @@
|
||||
#pragma mark -
|
||||
#pragma mark Initialization
|
||||
|
||||
+ (OZZipException *) zipExceptionWithReason:(NSString *)format, ... {
|
||||
|
||||
// Variable arguments formatting
|
||||
va_list arguments;
|
||||
va_start(arguments, format);
|
||||
NSString *reason= [[NSString alloc] initWithFormat:format arguments:arguments];
|
||||
va_end(arguments);
|
||||
|
||||
return [[OZZipException alloc] initWithReason:reason];
|
||||
}
|
||||
|
||||
+ (OZZipException *) zipExceptionWithError:(NSInteger)error reason:(NSString *)format, ... {
|
||||
|
||||
// Variable arguments formatting
|
||||
va_list arguments;
|
||||
va_start(arguments, format);
|
||||
NSString *reason= [[NSString alloc] initWithFormat:format arguments:arguments];
|
||||
va_end(arguments);
|
||||
|
||||
return [[OZZipException alloc] initWithError:error reason:reason];
|
||||
}
|
||||
|
||||
- (instancetype) initWithReason:(NSString *)reason {
|
||||
if (self= [super initWithName:@"OZZipException" reason:reason userInfo:nil]) {
|
||||
_error= 0;
|
||||
|
||||
@@ -50,6 +50,12 @@
|
||||
- (instancetype) initWithFileName:(NSString *)fileName mode:(OZZipFileMode)mode;
|
||||
- (instancetype) initWithFileName:(NSString *)fileName mode:(OZZipFileMode)mode legacy32BitMode:(BOOL)legacy32BitMode;
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Initialization (NSError variants)
|
||||
|
||||
- (instancetype) initWithFileName:(NSString *)fileName mode:(OZZipFileMode)mode error:(NSError * __autoreleasing *)error;
|
||||
- (instancetype) initWithFileName:(NSString *)fileName mode:(OZZipFileMode)mode legacy32BitMode:(BOOL)legacy32BitMode error:(NSError * __autoreleasing *)error;
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark File writing
|
||||
@@ -59,6 +65,14 @@
|
||||
- (OZZipWriteStream *) writeFileInZipWithName:(NSString *)fileNameInZip fileDate:(NSDate *)fileDate compressionLevel:(OZZipCompressionLevel)compressionLevel password:(NSString *)password crc32:(NSUInteger)crc32;
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark File writing (NSError variants)
|
||||
|
||||
- (OZZipWriteStream *) writeFileInZipWithName:(NSString *)fileNameInZip compressionLevel:(OZZipCompressionLevel)compressionLevel error:(NSError * __autoreleasing *)error;
|
||||
- (OZZipWriteStream *) writeFileInZipWithName:(NSString *)fileNameInZip fileDate:(NSDate *)fileDate compressionLevel:(OZZipCompressionLevel)compressionLevel error:(NSError * __autoreleasing *)error;
|
||||
- (OZZipWriteStream *) writeFileInZipWithName:(NSString *)fileNameInZip fileDate:(NSDate *)fileDate compressionLevel:(OZZipCompressionLevel)compressionLevel password:(NSString *)password crc32:(NSUInteger)crc32 error:(NSError * __autoreleasing *)error;
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark File seeking and info
|
||||
|
||||
@@ -66,10 +80,23 @@
|
||||
- (BOOL) goToNextFileInZip;
|
||||
- (BOOL) locateFileInZip:(NSString *)fileNameInZip;
|
||||
|
||||
- (NSUInteger) numFilesInZip;
|
||||
- (NSArray *) listFileInZipInfos;
|
||||
- (OZFileInZipInfo *) getCurrentFileInZipInfo;
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark File seeking and info (NSError variants)
|
||||
|
||||
- (void) goToFirstFileInZipWithError:(NSError * __autoreleasing *)error;
|
||||
- (BOOL) goToNextFileInZipWithError:(NSError * __autoreleasing *)error;
|
||||
- (BOOL) locateFileInZip:(NSString *)fileNameInZip error:(NSError * __autoreleasing *)error;
|
||||
|
||||
- (NSUInteger) numFilesInZipWithError:(NSError * __autoreleasing *)error;
|
||||
- (NSArray *) listFileInZipInfosWithError:(NSError * __autoreleasing *)error;
|
||||
- (OZFileInZipInfo *) getCurrentFileInZipInfoWithError:(NSError * __autoreleasing *)error;
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark File reading
|
||||
|
||||
@@ -77,12 +104,25 @@
|
||||
- (OZZipReadStream *) readCurrentFileInZipWithPassword:(NSString *)password;
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark File reading (NSError variants)
|
||||
|
||||
- (OZZipReadStream *) readCurrentFileInZipWithError:(NSError * __autoreleasing *)error;
|
||||
- (OZZipReadStream *) readCurrentFileInZipWithPassword:(NSString *)password error:(NSError * __autoreleasing *)error;
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Closing
|
||||
|
||||
- (void) close;
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Closing (NSError variants)
|
||||
|
||||
- (void) closeWithError:(NSError * __autoreleasing *)error;
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Properties
|
||||
|
||||
@@ -90,7 +130,5 @@
|
||||
@property (nonatomic, readonly) OZZipFileMode mode;
|
||||
@property (nonatomic, readonly) BOOL legacy32BitMode;
|
||||
|
||||
@property (nonatomic, readonly) NSUInteger numFilesInZip;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
+214
-147
@@ -90,36 +90,28 @@
|
||||
// Support for legacy 32 bit mode: here we use 32 or 64 bit version
|
||||
// alternatively, as internal (common) version is not exposed
|
||||
_unzFile= (_legacy32BitMode ? unzOpen(path) : unzOpen64(path));
|
||||
if (_unzFile == NULL) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Can't open '%@'", _fileName];
|
||||
@throw [[OZZipException alloc] initWithReason:reason];
|
||||
}
|
||||
if (_unzFile == NULL)
|
||||
@throw [OZZipException zipExceptionWithError:ERROR_NO_SUCH_FILE reason:@"Can't open '%@'", _fileName];
|
||||
break;
|
||||
|
||||
case OZZipFileModeCreate:
|
||||
|
||||
// Support for legacy 32 bit mode: here we use the common version
|
||||
_zipFile= zipOpen3(path, APPEND_STATUS_CREATE, 0, NULL, NULL);
|
||||
if (_zipFile == NULL) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Can't open '%@'", _fileName];
|
||||
@throw [[OZZipException alloc] initWithReason:reason];
|
||||
}
|
||||
if (_zipFile == NULL)
|
||||
@throw [OZZipException zipExceptionWithError:ERROR_NO_SUCH_FILE reason:@"Can't open '%@'", _fileName];
|
||||
break;
|
||||
|
||||
case OZZipFileModeAppend:
|
||||
|
||||
// Support for legacy 32 bit mode: here we use the common version
|
||||
_zipFile= zipOpen3(path, APPEND_STATUS_ADDINZIP, 0, NULL, NULL);
|
||||
if (_zipFile == NULL) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Can't open '%@'", _fileName];
|
||||
@throw [[OZZipException alloc] initWithReason:reason];
|
||||
}
|
||||
if (_zipFile == NULL)
|
||||
@throw [OZZipException zipExceptionWithError:ERROR_NO_SUCH_FILE reason:@"Can't open '%@'", _fileName];
|
||||
break;
|
||||
|
||||
default: {
|
||||
NSString *reason= [NSString stringWithFormat:@"Unknown mode %d", _mode];
|
||||
@throw [[OZZipException alloc] initWithReason:reason];
|
||||
}
|
||||
default:
|
||||
@throw [OZZipException zipExceptionWithReason:@"Unknown mode %d", _mode];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,14 +119,32 @@
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Initialization (NSError variants)
|
||||
|
||||
- (instancetype) initWithFileName:(NSString *)fileName mode:(OZZipFileMode)mode error:(NSError *__autoreleasing *)error {
|
||||
ERROR_WRAP_BEGIN {
|
||||
|
||||
return [self initWithFileName:fileName mode:mode];
|
||||
|
||||
} ERROR_WRAP_END(error);
|
||||
}
|
||||
|
||||
- (instancetype) initWithFileName:(NSString *)fileName mode:(OZZipFileMode)mode legacy32BitMode:(BOOL)legacy32BitMode error:(NSError *__autoreleasing *)error {
|
||||
ERROR_WRAP_BEGIN {
|
||||
|
||||
return [self initWithFileName:fileName mode:mode legacy32BitMode:legacy32BitMode];
|
||||
|
||||
} ERROR_WRAP_END(error);
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark File writing
|
||||
|
||||
- (OZZipWriteStream *) writeFileInZipWithName:(NSString *)fileNameInZip compressionLevel:(OZZipCompressionLevel)compressionLevel {
|
||||
if (_mode == OZZipFileModeUnzip) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Operation not permitted with Unzip mode"];
|
||||
@throw [[OZZipException alloc] initWithReason:reason];
|
||||
}
|
||||
if (_mode == OZZipFileModeUnzip)
|
||||
@throw [OZZipException zipExceptionWithReason:@"Operation not permitted in Unzip mode"];
|
||||
|
||||
NSDate *now= [NSDate date];
|
||||
NSCalendar *calendar= [NSCalendar currentCalendar];
|
||||
@@ -162,19 +172,15 @@
|
||||
NULL, 0,
|
||||
(_legacy32BitMode ? 0 : 1));
|
||||
|
||||
if (err != ZIP_OK) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Error opening '%@' in zipfile", fileNameInZip];
|
||||
@throw [[OZZipException alloc] initWithError:err reason:reason];
|
||||
}
|
||||
if (err != ZIP_OK)
|
||||
@throw [OZZipException zipExceptionWithError:err reason:@"Error opening '%@' in zipfile", fileNameInZip];
|
||||
|
||||
return [[OZZipWriteStream alloc] initWithZipFileStruct:_zipFile fileNameInZip:fileNameInZip];
|
||||
}
|
||||
|
||||
- (OZZipWriteStream *) writeFileInZipWithName:(NSString *)fileNameInZip fileDate:(NSDate *)fileDate compressionLevel:(OZZipCompressionLevel)compressionLevel {
|
||||
if (_mode == OZZipFileModeUnzip) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Operation not permitted with Unzip mode"];
|
||||
@throw [[OZZipException alloc] initWithReason:reason];
|
||||
}
|
||||
if (_mode == OZZipFileModeUnzip)
|
||||
@throw [OZZipException zipExceptionWithReason:@"Operation not permitted in Unzip mode"];
|
||||
|
||||
NSCalendar *calendar= [NSCalendar currentCalendar];
|
||||
NSDateComponents *date= [calendar components:(NSCalendarUnitSecond | NSCalendarUnitMinute | NSCalendarUnitHour | NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear) fromDate:fileDate];
|
||||
@@ -201,19 +207,15 @@
|
||||
NULL, 0,
|
||||
(_legacy32BitMode ? 0 : 1));
|
||||
|
||||
if (err != ZIP_OK) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Error opening '%@' in zipfile", fileNameInZip];
|
||||
@throw [[OZZipException alloc] initWithError:err reason:reason];
|
||||
}
|
||||
if (err != ZIP_OK)
|
||||
@throw [OZZipException zipExceptionWithError:err reason:@"Error opening '%@' in zipfile", fileNameInZip];
|
||||
|
||||
return [[OZZipWriteStream alloc] initWithZipFileStruct:_zipFile fileNameInZip:fileNameInZip];
|
||||
}
|
||||
|
||||
- (OZZipWriteStream *) writeFileInZipWithName:(NSString *)fileNameInZip fileDate:(NSDate *)fileDate compressionLevel:(OZZipCompressionLevel)compressionLevel password:(NSString *)password crc32:(NSUInteger)crc32 {
|
||||
if (_mode == OZZipFileModeUnzip) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Operation not permitted with Unzip mode"];
|
||||
@throw [[OZZipException alloc] initWithReason:reason];
|
||||
}
|
||||
if (_mode == OZZipFileModeUnzip)
|
||||
@throw [OZZipException zipExceptionWithReason:@"Operation not permitted in Unzip mode"];
|
||||
|
||||
NSCalendar *calendar= [NSCalendar currentCalendar];
|
||||
NSDateComponents *date= [calendar components:(NSCalendarUnitSecond | NSCalendarUnitMinute | NSCalendarUnitHour | NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear) fromDate:fileDate];
|
||||
@@ -240,71 +242,111 @@
|
||||
[password cStringUsingEncoding:NSUTF8StringEncoding], crc32,
|
||||
(_legacy32BitMode ? 0 : 1));
|
||||
|
||||
if (err != ZIP_OK) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Error opening '%@' in zipfile", fileNameInZip];
|
||||
@throw [[OZZipException alloc] initWithError:err reason:reason];
|
||||
}
|
||||
if (err != ZIP_OK)
|
||||
@throw [OZZipException zipExceptionWithError:err reason:@"Error opening '%@' in zipfile", fileNameInZip];
|
||||
|
||||
return [[OZZipWriteStream alloc] initWithZipFileStruct:_zipFile fileNameInZip:fileNameInZip];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark File writing (NSError variants)
|
||||
|
||||
- (OZZipWriteStream *) writeFileInZipWithName:(NSString *)fileNameInZip compressionLevel:(OZZipCompressionLevel)compressionLevel error:(NSError * __autoreleasing *)error {
|
||||
ERROR_WRAP_BEGIN {
|
||||
|
||||
return [self writeFileInZipWithName:fileNameInZip compressionLevel:compressionLevel];
|
||||
|
||||
} ERROR_WRAP_END(error);
|
||||
}
|
||||
|
||||
- (OZZipWriteStream *) writeFileInZipWithName:(NSString *)fileNameInZip fileDate:(NSDate *)fileDate compressionLevel:(OZZipCompressionLevel)compressionLevel error:(NSError * __autoreleasing *)error {
|
||||
ERROR_WRAP_BEGIN {
|
||||
|
||||
return [self writeFileInZipWithName:fileNameInZip fileDate:fileDate compressionLevel:compressionLevel];
|
||||
|
||||
} ERROR_WRAP_END(error);
|
||||
}
|
||||
|
||||
- (OZZipWriteStream *) writeFileInZipWithName:(NSString *)fileNameInZip fileDate:(NSDate *)fileDate compressionLevel:(OZZipCompressionLevel)compressionLevel password:(NSString *)password crc32:(NSUInteger)crc32 error:(NSError * __autoreleasing *)error {
|
||||
ERROR_WRAP_BEGIN {
|
||||
|
||||
return [self writeFileInZipWithName:fileNameInZip fileDate:fileDate compressionLevel:compressionLevel password:password crc32:crc32];
|
||||
|
||||
} ERROR_WRAP_END(error);
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark File seeking and info
|
||||
|
||||
- (void) goToFirstFileInZip {
|
||||
if (_mode != OZZipFileModeUnzip) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Operation not permitted without Unzip mode"];
|
||||
@throw [[OZZipException alloc] initWithReason:reason];
|
||||
}
|
||||
if (_mode != OZZipFileModeUnzip)
|
||||
@throw [OZZipException zipExceptionWithReason:@"Operation permitted only in Unzip mode"];
|
||||
|
||||
int err= unzGoToFirstFile(_unzFile);
|
||||
if (err != UNZ_OK) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Error going to first file in zip in '%@'", _fileName];
|
||||
@throw [[OZZipException alloc] initWithError:err reason:reason];
|
||||
}
|
||||
if (err != UNZ_OK)
|
||||
@throw [OZZipException zipExceptionWithError:err reason:@"Error going to first file in zip of '%@'", _fileName];
|
||||
}
|
||||
|
||||
- (BOOL) goToNextFileInZip {
|
||||
if (_mode != OZZipFileModeUnzip) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Operation not permitted without Unzip mode"];
|
||||
@throw [[OZZipException alloc] initWithReason:reason];
|
||||
}
|
||||
if (_mode != OZZipFileModeUnzip)
|
||||
@throw [OZZipException zipExceptionWithReason:@"Operation permitted only in Unzip mode"];
|
||||
|
||||
int err= unzGoToNextFile(_unzFile);
|
||||
if (err == UNZ_END_OF_LIST_OF_FILE)
|
||||
return NO;
|
||||
|
||||
if (err != UNZ_OK) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Error going to next file in zip in '%@'", _fileName];
|
||||
@throw [[OZZipException alloc] initWithError:err reason:reason];
|
||||
}
|
||||
if (err != UNZ_OK)
|
||||
@throw [OZZipException zipExceptionWithError:err reason:@"Error going to next file in zip of '%@'", _fileName];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) locateFileInZip:(NSString *)fileNameInZip {
|
||||
if (_mode != OZZipFileModeUnzip) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Operation not permitted without Unzip mode"];
|
||||
@throw [[OZZipException alloc] initWithReason:reason];
|
||||
}
|
||||
if (_mode != OZZipFileModeUnzip)
|
||||
@throw [OZZipException zipExceptionWithReason:@"Operation permitted only in Unzip mode"];
|
||||
|
||||
int err= unzLocateFile(_unzFile, [fileNameInZip cStringUsingEncoding:NSUTF8StringEncoding], NULL);
|
||||
if (err == UNZ_END_OF_LIST_OF_FILE)
|
||||
return NO;
|
||||
|
||||
if (err != UNZ_OK) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Error localting file in zip in '%@'", _fileName];
|
||||
@throw [[OZZipException alloc] initWithError:err reason:reason];
|
||||
}
|
||||
if (err != UNZ_OK)
|
||||
@throw [OZZipException zipExceptionWithError:err reason:@"Error localting file in zip of '%@'", _fileName];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSUInteger) numFilesInZip {
|
||||
if (_mode != OZZipFileModeUnzip)
|
||||
@throw [OZZipException zipExceptionWithReason:@"Operation permitted only in Unzip mode"];
|
||||
|
||||
// Support for legacy 32 bit mode: here we use the 32 or 64 bit
|
||||
// version alternatively, as there is not internal (common) version
|
||||
if (_legacy32BitMode) {
|
||||
unz_global_info gi;
|
||||
|
||||
int err= unzGetGlobalInfo(_unzFile, &gi);
|
||||
if (err != UNZ_OK)
|
||||
@throw [OZZipException zipExceptionWithError:err reason:@"Error getting global info of '%@'", _fileName];
|
||||
|
||||
return gi.number_entry;
|
||||
|
||||
} else {
|
||||
unz_global_info64 gi;
|
||||
|
||||
int err= unzGetGlobalInfo64(_unzFile, &gi);
|
||||
if (err != UNZ_OK)
|
||||
@throw [OZZipException zipExceptionWithError:err reason:@"Error getting global info of '%@'", _fileName];
|
||||
|
||||
return gi.number_entry;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *) listFileInZipInfos {
|
||||
NSUInteger num= [self numFilesInZip];
|
||||
if (num < 1)
|
||||
return [[NSArray alloc] init];
|
||||
return [NSArray array];
|
||||
|
||||
NSMutableArray *files= [[NSMutableArray alloc] initWithCapacity:num];
|
||||
|
||||
@@ -321,10 +363,8 @@
|
||||
}
|
||||
|
||||
- (OZFileInZipInfo *) getCurrentFileInZipInfo {
|
||||
if (_mode != OZZipFileModeUnzip) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Operation not permitted without Unzip mode"];
|
||||
@throw [[OZZipException alloc] initWithReason:reason];
|
||||
}
|
||||
if (_mode != OZZipFileModeUnzip)
|
||||
@throw [OZZipException zipExceptionWithReason:@"Operation permitted only in Unzip mode"];
|
||||
|
||||
char filename_inzip[FILE_IN_ZIP_MAX_NAME_LENGTH];
|
||||
unz_file_info64 file_info;
|
||||
@@ -332,10 +372,8 @@
|
||||
// Support for legacy 32 bit mode: here we use the 64 bit version,
|
||||
// as it also internally called from the 32 bit version
|
||||
int err= unzGetCurrentFileInfo64(_unzFile, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0, NULL, 0);
|
||||
if (err != UNZ_OK) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Error getting current file info in '%@'", _fileName];
|
||||
@throw [[OZZipException alloc] initWithError:err reason:reason];
|
||||
}
|
||||
if (err != UNZ_OK)
|
||||
@throw [OZZipException zipExceptionWithError:err reason:@"Error getting current file info of '%@'", _fileName];
|
||||
|
||||
NSString *name= [NSString stringWithCString:filename_inzip encoding:NSUTF8StringEncoding];
|
||||
|
||||
@@ -373,14 +411,64 @@
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark File seeking and info (NSError variants)
|
||||
|
||||
- (void) goToFirstFileInZipWithError:(NSError * __autoreleasing *)error {
|
||||
ERROR_WRAP_BEGIN {
|
||||
|
||||
[self goToFirstFileInZip];
|
||||
|
||||
} ERROR_WRAP_END(error);
|
||||
}
|
||||
|
||||
- (BOOL) goToNextFileInZipWithError:(NSError * __autoreleasing *)error {
|
||||
ERROR_WRAP_BEGIN {
|
||||
|
||||
return [self goToNextFileInZip];
|
||||
|
||||
} ERROR_WRAP_END(error);
|
||||
}
|
||||
|
||||
- (BOOL) locateFileInZip:(NSString *)fileNameInZip error:(NSError * __autoreleasing *)error {
|
||||
ERROR_WRAP_BEGIN {
|
||||
|
||||
return [self locateFileInZip:fileNameInZip];
|
||||
|
||||
} ERROR_WRAP_END(error);
|
||||
}
|
||||
|
||||
- (NSUInteger) numFilesInZipWithError:(NSError * __autoreleasing *)error {
|
||||
ERROR_WRAP_BEGIN {
|
||||
|
||||
return [self numFilesInZip];
|
||||
|
||||
} ERROR_WRAP_END(error);
|
||||
}
|
||||
|
||||
- (NSArray *) listFileInZipInfosWithError:(NSError * __autoreleasing *)error {
|
||||
ERROR_WRAP_BEGIN {
|
||||
|
||||
return [self listFileInZipInfos];
|
||||
|
||||
} ERROR_WRAP_END(error);
|
||||
}
|
||||
|
||||
- (OZFileInZipInfo *) getCurrentFileInZipInfoWithError:(NSError * __autoreleasing *)error {
|
||||
ERROR_WRAP_BEGIN {
|
||||
|
||||
return [self getCurrentFileInZipInfo];
|
||||
|
||||
} ERROR_WRAP_END(error);
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark File reading
|
||||
|
||||
- (OZZipReadStream *) readCurrentFileInZip {
|
||||
if (_mode != OZZipFileModeUnzip) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Operation not permitted without Unzip mode"];
|
||||
@throw [[OZZipException alloc] initWithReason:reason];
|
||||
}
|
||||
if (_mode != OZZipFileModeUnzip)
|
||||
@throw [OZZipException zipExceptionWithReason:@"Operation permitted only in Unzip mode"];
|
||||
|
||||
char filename_inzip[FILE_IN_ZIP_MAX_NAME_LENGTH];
|
||||
unz_file_info64 file_info;
|
||||
@@ -388,27 +476,21 @@
|
||||
// Support for legacy 32 bit mode: here we use the 64 bit version,
|
||||
// as it also internally called from the 32 bit version
|
||||
int err= unzGetCurrentFileInfo64(_unzFile, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0, NULL, 0);
|
||||
if (err != UNZ_OK) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Error getting current file info in '%@'", _fileName];
|
||||
@throw [[OZZipException alloc] initWithError:err reason:reason];
|
||||
}
|
||||
if (err != UNZ_OK)
|
||||
@throw [OZZipException zipExceptionWithError:err reason:@"Error getting current file info of '%@'", _fileName];
|
||||
|
||||
NSString *fileNameInZip= [NSString stringWithCString:filename_inzip encoding:NSUTF8StringEncoding];
|
||||
|
||||
err= unzOpenCurrentFilePassword(_unzFile, NULL);
|
||||
if (err != UNZ_OK) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Error opening current file in '%@'", _fileName];
|
||||
@throw [[OZZipException alloc] initWithError:err reason:reason];
|
||||
}
|
||||
if (err != UNZ_OK)
|
||||
@throw [OZZipException zipExceptionWithError:err reason:@"Error opening current file of '%@'", _fileName];
|
||||
|
||||
return [[OZZipReadStream alloc] initWithUnzFileStruct:_unzFile fileNameInZip:fileNameInZip];
|
||||
}
|
||||
|
||||
- (OZZipReadStream *) readCurrentFileInZipWithPassword:(NSString *)password {
|
||||
if (_mode != OZZipFileModeUnzip) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Operation not permitted without Unzip mode"];
|
||||
@throw [[OZZipException alloc] initWithReason:reason];
|
||||
}
|
||||
if (_mode != OZZipFileModeUnzip)
|
||||
@throw [OZZipException zipExceptionWithReason:@"Operation permitted only in Unzip mode"];
|
||||
|
||||
char filename_inzip[FILE_IN_ZIP_MAX_NAME_LENGTH];
|
||||
unz_file_info64 file_info;
|
||||
@@ -416,23 +498,39 @@
|
||||
// Support for legacy 32 bit mode: here we use the 64 bit version,
|
||||
// as it also internally called from the 32 bit version
|
||||
int err= unzGetCurrentFileInfo64(_unzFile, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0, NULL, 0);
|
||||
if (err != UNZ_OK) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Error getting current file info in '%@'", _fileName];
|
||||
@throw [[OZZipException alloc] initWithError:err reason:reason];
|
||||
}
|
||||
if (err != UNZ_OK)
|
||||
@throw [OZZipException zipExceptionWithError:err reason:@"Error getting current file info of '%@'", _fileName];
|
||||
|
||||
NSString *fileNameInZip= [NSString stringWithCString:filename_inzip encoding:NSUTF8StringEncoding];
|
||||
|
||||
err= unzOpenCurrentFilePassword(_unzFile, [password cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
if (err != UNZ_OK) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Error opening current file in '%@'", _fileName];
|
||||
@throw [[OZZipException alloc] initWithError:err reason:reason];
|
||||
}
|
||||
if (err != UNZ_OK)
|
||||
@throw [OZZipException zipExceptionWithError:err reason:@"Error opening current file of '%@'", _fileName];
|
||||
|
||||
return [[OZZipReadStream alloc] initWithUnzFileStruct:_unzFile fileNameInZip:fileNameInZip];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark File reading (NSError variants)
|
||||
|
||||
- (OZZipReadStream *) readCurrentFileInZipWithError:(NSError * __autoreleasing *)error {
|
||||
ERROR_WRAP_BEGIN {
|
||||
|
||||
return [self readCurrentFileInZip];
|
||||
|
||||
} ERROR_WRAP_END(error);
|
||||
}
|
||||
|
||||
- (OZZipReadStream *) readCurrentFileInZipWithPassword:(NSString *)password error:(NSError * __autoreleasing *)error {
|
||||
ERROR_WRAP_BEGIN {
|
||||
|
||||
return [self readCurrentFileInZipWithPassword:password];
|
||||
|
||||
} ERROR_WRAP_END(error);
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Closing
|
||||
|
||||
@@ -440,38 +538,41 @@
|
||||
switch (_mode) {
|
||||
case OZZipFileModeUnzip: {
|
||||
int err= unzClose(_unzFile);
|
||||
if (err != UNZ_OK) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Error closing '%@'", _fileName];
|
||||
@throw [[OZZipException alloc] initWithError:err reason:reason];
|
||||
}
|
||||
if (err != UNZ_OK)
|
||||
@throw [OZZipException zipExceptionWithError:err reason:@"Error closing '%@'", _fileName];
|
||||
break;
|
||||
}
|
||||
|
||||
case OZZipFileModeCreate: {
|
||||
int err= zipClose(_zipFile, NULL);
|
||||
if (err != ZIP_OK) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Error closing '%@'", _fileName];
|
||||
@throw [[OZZipException alloc] initWithError:err reason:reason];
|
||||
}
|
||||
if (err != ZIP_OK)
|
||||
@throw [OZZipException zipExceptionWithError:err reason:@"Error closing '%@'", _fileName];
|
||||
break;
|
||||
}
|
||||
|
||||
case OZZipFileModeAppend: {
|
||||
int err= zipClose(_zipFile, NULL);
|
||||
if (err != ZIP_OK) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Error closing '%@'", _fileName];
|
||||
@throw [[OZZipException alloc] initWithError:err reason:reason];
|
||||
}
|
||||
if (err != ZIP_OK)
|
||||
@throw [OZZipException zipExceptionWithError:err reason:@"Error closing '%@'", _fileName];
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
NSString *reason= [NSString stringWithFormat:@"Unknown mode %d", _mode];
|
||||
@throw [[OZZipException alloc] initWithReason:reason];
|
||||
}
|
||||
default:
|
||||
@throw [OZZipException zipExceptionWithReason:@"Unknown mode %d", _mode];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Closing (NSError variants)
|
||||
|
||||
- (void) closeWithError:(NSError * __autoreleasing *)error {
|
||||
ERROR_WRAP_BEGIN {
|
||||
|
||||
[self close];
|
||||
|
||||
} ERROR_WRAP_END(error);
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Properties
|
||||
@@ -480,39 +581,5 @@
|
||||
@synthesize mode= _mode;
|
||||
@synthesize legacy32BitMode= _legacy32BitMode;
|
||||
|
||||
@dynamic numFilesInZip;
|
||||
|
||||
- (NSUInteger) numFilesInZip {
|
||||
if (_mode != OZZipFileModeUnzip) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Operation not permitted without Unzip mode"];
|
||||
@throw [[OZZipException alloc] initWithReason:reason];
|
||||
}
|
||||
|
||||
// Support for legacy 32 bit mode: here we use the 32 or 64 bit
|
||||
// version alternatively, as there is not internal (common) version
|
||||
if (_legacy32BitMode) {
|
||||
unz_global_info gi;
|
||||
|
||||
int err= unzGetGlobalInfo(_unzFile, &gi);
|
||||
if (err != UNZ_OK) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Error getting global info in '%@'", _fileName];
|
||||
@throw [[OZZipException alloc] initWithError:err reason:reason];
|
||||
}
|
||||
|
||||
return gi.number_entry;
|
||||
|
||||
} else {
|
||||
unz_global_info64 gi;
|
||||
|
||||
int err= unzGetGlobalInfo64(_unzFile, &gi);
|
||||
if (err != UNZ_OK) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Error getting global info in '%@'", _fileName];
|
||||
@throw [[OZZipException alloc] initWithError:err reason:reason];
|
||||
}
|
||||
|
||||
return gi.number_entry;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -44,4 +44,11 @@
|
||||
- (void) finishedReading;
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Reading data (NSError variants)
|
||||
|
||||
- (NSUInteger) readDataWithBuffer:(NSMutableData *)buffer error:(NSError * __autoreleasing *)error;
|
||||
- (void) finishedReadingWithError:(NSError * __autoreleasing *)error;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -75,20 +75,36 @@
|
||||
|
||||
- (NSUInteger) readDataWithBuffer:(NSMutableData *)buffer {
|
||||
int err= unzReadCurrentFile(_unzFile, [buffer mutableBytes], (uInt) [buffer length]);
|
||||
if (err < 0) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Error reading '%@' in the zipfile", _fileNameInZip];
|
||||
@throw [[OZZipException alloc] initWithError:err reason:reason];
|
||||
}
|
||||
if (err < 0)
|
||||
@throw [OZZipException zipExceptionWithError:err reason:@"Error reading '%@' in the zipfile", _fileNameInZip];
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
- (void) finishedReading {
|
||||
int err= unzCloseCurrentFile(_unzFile);
|
||||
if (err != UNZ_OK) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Error closing '%@' in the zipfile", _fileNameInZip];
|
||||
@throw [[OZZipException alloc] initWithError:err reason:reason];
|
||||
}
|
||||
if (err != UNZ_OK)
|
||||
@throw [OZZipException zipExceptionWithError:err reason:@"Error closing '%@' in the zipfile", _fileNameInZip];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Reading data (NSError variants)
|
||||
|
||||
- (NSUInteger) readDataWithBuffer:(NSMutableData *)buffer error:(NSError * __autoreleasing *)error {
|
||||
ERROR_WRAP_BEGIN {
|
||||
|
||||
[self readDataWithBuffer:buffer];
|
||||
|
||||
} ERROR_WRAP_END(error);
|
||||
}
|
||||
|
||||
- (void) finishedReadingWithError:(NSError * __autoreleasing *)error {
|
||||
ERROR_WRAP_BEGIN {
|
||||
|
||||
[self finishedReading];
|
||||
|
||||
} ERROR_WRAP_END(error);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -44,4 +44,11 @@
|
||||
- (void) finishedWriting;
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Writing data (NSError variants)
|
||||
|
||||
- (void) writeData:(NSData *)data error:(NSError * __autoreleasing *)error;
|
||||
- (void) finishedWritingWithError:(NSError * __autoreleasing *)error;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -75,18 +75,34 @@
|
||||
|
||||
- (void) writeData:(NSData *)data {
|
||||
int err= zipWriteInFileInZip(_zipFile, [data bytes], (uInt) [data length]);
|
||||
if (err < 0) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Error writing '%@' in the zipfile", _fileNameInZip];
|
||||
@throw [[OZZipException alloc] initWithError:err reason:reason];
|
||||
}
|
||||
if (err < 0)
|
||||
@throw [OZZipException zipExceptionWithError:err reason:@"Error writing '%@' in the zipfile", _fileNameInZip];
|
||||
}
|
||||
|
||||
- (void) finishedWriting {
|
||||
int err= zipCloseFileInZip(_zipFile);
|
||||
if (err != ZIP_OK) {
|
||||
NSString *reason= [NSString stringWithFormat:@"Error closing '%@' in the zipfile", _fileNameInZip];
|
||||
@throw [[OZZipException alloc] initWithError:err reason:reason];
|
||||
}
|
||||
if (err != ZIP_OK)
|
||||
@throw [OZZipException zipExceptionWithError:err reason:@"Error closing '%@' in the zipfile", _fileNameInZip];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Writing data (NSError variants)
|
||||
|
||||
- (void) writeData:(NSData *)data error:(NSError * __autoreleasing *)error {
|
||||
ERROR_WRAP_BEGIN {
|
||||
|
||||
[self writeData:data];
|
||||
|
||||
} ERROR_WRAP_END(error);
|
||||
}
|
||||
|
||||
- (void) finishedWritingWithError:(NSError * __autoreleasing *)error {
|
||||
ERROR_WRAP_BEGIN {
|
||||
|
||||
[self finishedWriting];
|
||||
|
||||
} ERROR_WRAP_END(error);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -74,6 +74,26 @@
|
||||
<int key="NSfFlags">16</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBUIButton" id="416200362">
|
||||
<reference key="NSNextResponder" ref="774585933"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{20, 196}, {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>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<int key="IBUIContentHorizontalAlignment">0</int>
|
||||
<int key="IBUIContentVerticalAlignment">0</int>
|
||||
<int key="IBUIButtonType">1</int>
|
||||
<reference key="IBUINormalTitleColor" ref="803445480"/>
|
||||
<reference key="IBUIHighlightedTitleColor" ref="884333554"/>
|
||||
<string key="IBUINormalTitle">Error Wrapping</string>
|
||||
<reference key="IBUINormalTitleShadowColor" ref="114389561"/>
|
||||
<reference key="IBUIFontDescription" ref="975473552"/>
|
||||
<reference key="IBUIFont" ref="64712977"/>
|
||||
</object>
|
||||
<object class="IBUIButton" id="690801101">
|
||||
<reference key="NSNextResponder" ref="774585933"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
@@ -120,7 +140,7 @@
|
||||
<string key="NSFrame">{{20, 152}, {280, 37}}</string>
|
||||
<reference key="NSSuperview" ref="774585933"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="261814878"/>
|
||||
<reference key="NSNextKeyView" ref="416200362"/>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
@@ -137,7 +157,7 @@
|
||||
<object class="IBUIView" id="261814878">
|
||||
<reference key="NSNextResponder" ref="774585933"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{20, 196}, {280, 244}}</string>
|
||||
<string key="NSFrame">{{20, 243}, {280, 197}}</string>
|
||||
<reference key="NSSuperview" ref="774585933"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="718446055"/>
|
||||
@@ -152,9 +172,10 @@
|
||||
<object class="IBUITextView" id="718446055">
|
||||
<reference key="NSNextResponder" ref="774585933"/>
|
||||
<int key="NSvFlags">274</int>
|
||||
<string key="NSFrame">{{20, 196}, {280, 244}}</string>
|
||||
<string key="NSFrame">{{20, 243}, {280, 197}}</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>
|
||||
@@ -184,7 +205,7 @@
|
||||
<string key="NSFrame">{{0, 20}, {320, 460}}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<reference key="NSNextKeyView" ref="422324197"/>
|
||||
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
|
||||
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
|
||||
<object class="IBUISimulatedSizeMetrics" key="IBUISimulatedDestinationMetrics">
|
||||
@@ -248,6 +269,15 @@
|
||||
</object>
|
||||
<int key="connectionID">23</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchEventConnection" key="connection">
|
||||
<string key="label">errorWrapping</string>
|
||||
<reference key="source" ref="416200362"/>
|
||||
<reference key="destination" ref="843779117"/>
|
||||
<int key="IBEventType">7</int>
|
||||
</object>
|
||||
<int key="connectionID">26</int>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<array key="orderedObjects">
|
||||
@@ -275,9 +305,10 @@
|
||||
<reference ref="422324197"/>
|
||||
<reference ref="261814878"/>
|
||||
<reference ref="718446055"/>
|
||||
<reference ref="690801101"/>
|
||||
<reference ref="1005186811"/>
|
||||
<reference ref="68194376"/>
|
||||
<reference ref="416200362"/>
|
||||
<reference ref="690801101"/>
|
||||
</array>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
@@ -312,6 +343,11 @@
|
||||
<reference key="object" ref="68194376"/>
|
||||
<reference key="parent" ref="774585933"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">24</int>
|
||||
<reference key="object" ref="416200362"/>
|
||||
<reference key="parent" ref="774585933"/>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<dictionary class="NSMutableDictionary" key="flattenedProperties">
|
||||
@@ -323,6 +359,7 @@
|
||||
<string key="15.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="18.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="19.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="24.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<reference key="6.IBNSViewMetadataGestureRecognizers" ref="0"/>
|
||||
<string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="8.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
@@ -332,7 +369,7 @@
|
||||
<nil key="activeLocalization"/>
|
||||
<dictionary class="NSMutableDictionary" key="localizations"/>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">23</int>
|
||||
<int key="maxID">26</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
@@ -340,12 +377,17 @@
|
||||
<string key="className">Objective_ZipViewController</string>
|
||||
<string key="superclassName">UIViewController</string>
|
||||
<dictionary class="NSMutableDictionary" key="actions">
|
||||
<string key="errorWrapping">id</string>
|
||||
<string key="zipCheck1">id</string>
|
||||
<string key="zipCheck2">id</string>
|
||||
<string key="zipUnzip">id</string>
|
||||
<string key="zipUnzip2">id</string>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="actionInfosByName">
|
||||
<object class="IBActionInfo" key="errorWrapping">
|
||||
<string key="name">errorWrapping</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo" key="zipCheck1">
|
||||
<string key="name">zipCheck1</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
@@ -382,12 +424,17 @@
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">Objective_ZipViewController</string>
|
||||
<dictionary class="NSMutableDictionary" key="actions">
|
||||
<string key="errorWrapping">id</string>
|
||||
<string key="zipCheck1">id</string>
|
||||
<string key="zipCheck2">id</string>
|
||||
<string key="zipUnzip">id</string>
|
||||
<string key="zipUnzip2">id</string>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="actionInfosByName">
|
||||
<object class="IBActionInfo" key="errorWrapping">
|
||||
<string key="name">errorWrapping</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo" key="zipCheck1">
|
||||
<string key="name">zipCheck1</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
|
||||
Reference in New Issue
Block a user