Public constants for error domain and error codes
This commit is contained in:
@@ -14,6 +14,14 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
extern NSString *const SSZipArchiveErrorDomain = @"SSZipArchiveErrorDomain";
|
||||
typedef NS_ENUM(NSInteger, SSZipArchiveErrorCode) {
|
||||
SSZipArchiveErrorCodeFailedOpenZipFile = -1,
|
||||
SSZipArchiveErrorCodeFailedOpenFirstFile = -2,
|
||||
SSZipArchiveErrorCodeFileInfoNotLoadable = -3,
|
||||
SSZipArchiveErrorCodeFileContentNotReadable = -4,
|
||||
};
|
||||
|
||||
@protocol SSZipArchiveDelegate;
|
||||
|
||||
@interface SSZipArchive : NSObject
|
||||
|
||||
+11
-11
@@ -67,8 +67,8 @@
|
||||
zipFile zip = unzOpen((const char*)[path UTF8String]);
|
||||
if (zip == NULL) {
|
||||
if (error) {
|
||||
*error = [NSError errorWithDomain:@"SSZipArchiveErrorDomain"
|
||||
code:-1
|
||||
*error = [NSError errorWithDomain:SSZipArchiveErrorDomain
|
||||
code:SSZipArchiveErrorCodeFailedOpenZipFile
|
||||
userInfo:@{NSLocalizedDescriptionKey: @"failed to open zip file"}];
|
||||
}
|
||||
return NO;
|
||||
@@ -85,8 +85,8 @@
|
||||
if (ret != UNZ_OK) {
|
||||
if (ret != UNZ_BADPASSWORD) {
|
||||
if (error) {
|
||||
*error = [NSError errorWithDomain:@"SSZipArchiveErrorDomain"
|
||||
code:-2
|
||||
*error = [NSError errorWithDomain:SSZipArchiveErrorDomain
|
||||
code:SSZipArchiveErrorCodeFailedOpenFirstFile
|
||||
userInfo:@{NSLocalizedDescriptionKey: @"failed to open first file in zip file"}];
|
||||
}
|
||||
}
|
||||
@@ -96,8 +96,8 @@
|
||||
ret = unzGetCurrentFileInfo(zip, &fileInfo, NULL, 0, NULL, 0, NULL, 0);
|
||||
if (ret != UNZ_OK) {
|
||||
if (error) {
|
||||
*error = [NSError errorWithDomain:@"SSZipArchiveErrorDomain"
|
||||
code:-3
|
||||
*error = [NSError errorWithDomain:SSZipArchiveErrorDomain
|
||||
code:SSZipArchiveErrorCodeFileInfoNotLoadable
|
||||
userInfo:@{NSLocalizedDescriptionKey: @"failed to retrieve info for file"}];
|
||||
}
|
||||
return NO;
|
||||
@@ -108,8 +108,8 @@
|
||||
// Let's assume the invalid password caused this error
|
||||
if (readBytes != Z_DATA_ERROR) {
|
||||
if (error) {
|
||||
*error = [NSError errorWithDomain:@"SSZipArchiveErrorDomain"
|
||||
code:-4
|
||||
*error = [NSError errorWithDomain:SSZipArchiveErrorDomain
|
||||
code:SSZipArchiveErrorCodeFileContentNotReadable
|
||||
userInfo:@{NSLocalizedDescriptionKey: @"failed to read contents of file entry"}];
|
||||
}
|
||||
}
|
||||
@@ -194,7 +194,7 @@
|
||||
if (zip == NULL)
|
||||
{
|
||||
NSDictionary *userInfo = @{NSLocalizedDescriptionKey: @"failed to open zip file"};
|
||||
NSError *err = [NSError errorWithDomain:@"SSZipArchiveErrorDomain" code:-1 userInfo:userInfo];
|
||||
NSError *err = [NSError errorWithDomain:SSZipArchiveErrorDomain code:SSZipArchiveErrorCodeFailedOpenZipFile userInfo:userInfo];
|
||||
if (error)
|
||||
{
|
||||
*error = err;
|
||||
@@ -217,7 +217,7 @@
|
||||
if (unzGoToFirstFile(zip) != UNZ_OK)
|
||||
{
|
||||
NSDictionary *userInfo = @{NSLocalizedDescriptionKey: @"failed to open first file in zip file"};
|
||||
NSError *err = [NSError errorWithDomain:@"SSZipArchiveErrorDomain" code:-2 userInfo:userInfo];
|
||||
NSError *err = [NSError errorWithDomain:SSZipArchiveErrorDomain code:SSZipArchiveErrorCodeFailedOpenFirstFile userInfo:userInfo];
|
||||
if (error)
|
||||
{
|
||||
*error = err;
|
||||
@@ -530,7 +530,7 @@
|
||||
if (crc_ret == UNZ_CRCERROR)
|
||||
{
|
||||
NSDictionary *userInfo = @{NSLocalizedDescriptionKey: @"crc check failed for file"};
|
||||
retErr = [NSError errorWithDomain:@"SSZipArchiveErrorDomain" code:-3 userInfo:userInfo];
|
||||
retErr = [NSError errorWithDomain:SSZipArchiveErrorDomain code:SSZipArchiveErrorCodeFileInfoNotLoadable userInfo:userInfo];
|
||||
}
|
||||
|
||||
if (error) {
|
||||
|
||||
Reference in New Issue
Block a user