Use zip_error_strerror and zip_discard if available
parent
4d517e992f
commit
5da8f1872b
|
@ -56,7 +56,14 @@
|
||||||
int errorp;
|
int errorp;
|
||||||
self->z = zip_open([file cString], ZIP_CREATE | ZIP_EXCL, &errorp);
|
self->z = zip_open([file cString], ZIP_CREATE | ZIP_EXCL, &errorp);
|
||||||
if (self->z == NULL) {
|
if (self->z == NULL) {
|
||||||
NSLog(@"Failed to open zip output file %@: %@", file, zip_strerror(self->z));
|
#if defined(LIBZIP_VERSION_MAJOR) && LIBZIP_VERSION_MAJOR >= 1
|
||||||
|
zip_error_t ziperror;
|
||||||
|
zip_error_init_with_code(&ziperror, errorp);
|
||||||
|
NSLog(@"Failed to open zip output file %@: %@", file,
|
||||||
|
[NSString stringWithCString: zip_error_strerror(&ziperror)]);
|
||||||
|
#else
|
||||||
|
NSLog(@"Failed to open zip output file %@", file);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
ret = self;
|
ret = self;
|
||||||
}
|
}
|
||||||
|
@ -100,6 +107,9 @@
|
||||||
if (self->z != NULL) {
|
if (self->z != NULL) {
|
||||||
if (zip_close(self->z) != 0) {
|
if (zip_close(self->z) != 0) {
|
||||||
NSLog(@"Failed to close zip archive: %@", [NSString stringWithCString: zip_strerror(self->z)]);
|
NSLog(@"Failed to close zip archive: %@", [NSString stringWithCString: zip_strerror(self->z)]);
|
||||||
|
#if defined(LIBZIP_VERSION_MAJOR) && (LIBZIP_VERSION_MAJOR >= 1 || LIBZIP_VERSION_MINOR >= 11)
|
||||||
|
zip_discard(self->z);
|
||||||
|
#endif
|
||||||
success = NO;
|
success = NO;
|
||||||
}
|
}
|
||||||
self->z = NULL;
|
self->z = NULL;
|
||||||
|
|
Loading…
Reference in New Issue