Skip to content

Commit

Permalink
Merge pull request #282 from jkanefendt/libzip-compat
Browse files Browse the repository at this point in the history
Use zip_error_strerror and zip_discard if available
  • Loading branch information
extrafu committed Jun 23, 2020
2 parents 3d3b17a + 5da8f18 commit b3dd794
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion SoObjects/SOGo/SOGoZipArchiver.m
Expand Up @@ -56,7 +56,14 @@ - (id)initFromFile:(NSString *)file
int errorp;
self->z = zip_open([file cString], ZIP_CREATE | ZIP_EXCL, &errorp);
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 {
ret = self;
}
Expand Down Expand Up @@ -100,6 +107,9 @@ - (BOOL)close
if (self->z != NULL) {
if (zip_close(self->z) != 0) {
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;
}
self->z = NULL;
Expand Down

0 comments on commit b3dd794

Please sign in to comment.