@@ -21,6 +21,7 @@ typedef NS_ENUM(NSInteger, SSZipArchiveErrorCode) {
|
|||||||
SSZipArchiveErrorCodeFileInfoNotLoadable = -3,
|
SSZipArchiveErrorCodeFileInfoNotLoadable = -3,
|
||||||
SSZipArchiveErrorCodeFileContentNotReadable = -4,
|
SSZipArchiveErrorCodeFileContentNotReadable = -4,
|
||||||
SSZipArchiveErrorCodeFailedToWriteFile = -5,
|
SSZipArchiveErrorCodeFailedToWriteFile = -5,
|
||||||
|
SSZipArchiveErrorCodeInvalidArguments = -6,
|
||||||
};
|
};
|
||||||
|
|
||||||
@protocol SSZipArchiveDelegate;
|
@protocol SSZipArchiveDelegate;
|
||||||
|
|||||||
@@ -184,12 +184,28 @@ NSString *const SSZipArchiveErrorDomain = @"SSZipArchiveErrorDomain";
|
|||||||
toDestination:(NSString *)destination
|
toDestination:(NSString *)destination
|
||||||
preserveAttributes:(BOOL)preserveAttributes
|
preserveAttributes:(BOOL)preserveAttributes
|
||||||
overwrite:(BOOL)overwrite
|
overwrite:(BOOL)overwrite
|
||||||
password:(NSString *)password
|
password:(nullable NSString *)password
|
||||||
error:(NSError **)error
|
error:(NSError **)error
|
||||||
delegate:(id<SSZipArchiveDelegate>)delegate
|
delegate:(id<SSZipArchiveDelegate>)delegate
|
||||||
progressHandler:(void (^)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
|
progressHandler:(void (^)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
|
||||||
completionHandler:(void (^)(NSString *path, BOOL succeeded, NSError * __nullable error))completionHandler
|
completionHandler:(void (^)(NSString *path, BOOL succeeded, NSError * __nullable error))completionHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Guard against empty strings
|
||||||
|
if ([path length] == 0 || [destination length] == 0)
|
||||||
|
{
|
||||||
|
NSDictionary *userInfo = @{NSLocalizedDescriptionKey: @"received invalid argument(s)"};
|
||||||
|
NSError *err = [NSError errorWithDomain:SSZipArchiveErrorDomain code:SSZipArchiveErrorCodeInvalidArguments userInfo:userInfo];
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
*error = err;
|
||||||
|
}
|
||||||
|
if (completionHandler)
|
||||||
|
{
|
||||||
|
completionHandler(nil, NO, err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Begin opening
|
// Begin opening
|
||||||
zipFile zip = unzOpen((const char*)[path fileSystemRepresentation]);
|
zipFile zip = unzOpen((const char*)[path fileSystemRepresentation]);
|
||||||
if (zip == NULL)
|
if (zip == NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user