55// Created by Sam Soffes on 7/21/10.
66// Copyright (c) Sam Soffes 2010-2015. All rights reserved.
77//
8- #import " SSZipArchive .h"
8+ #import " RNZASSZipArchive .h"
99#include " unzip.h"
1010#include " zip.h"
1111#import " zlib.h"
1515
1616#define CHUNK 16384
1717
18- @interface SSZipArchive ()
18+ @interface RNZASSZipArchive ()
1919+ (NSDate *)_dateWithMSDOSFormat : (UInt32)msdosDateTime ;
2020@end
2121
22- @implementation SSZipArchive
22+ @implementation RNZASSZipArchive
2323{
2424 NSString *_path;
2525 NSString *_filename;
@@ -71,12 +71,12 @@ + (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination o
7171 return [self unzipFileAtPath: path toDestination: destination preserveAttributes: YES overwrite: overwrite password: password error: error delegate: nil progressHandler: nil completionHandler: nil ];
7272}
7373
74- + (BOOL )unzipFileAtPath : (NSString *)path toDestination : (NSString *)destination delegate : (nullable id <SSZipArchiveDelegate >)delegate
74+ + (BOOL )unzipFileAtPath : (NSString *)path toDestination : (NSString *)destination delegate : (nullable id <RNZASSZipArchiveDelegate >)delegate
7575{
7676 return [self unzipFileAtPath: path toDestination: destination preserveAttributes: YES overwrite: YES password: nil error: nil delegate: delegate progressHandler: nil completionHandler: nil ];
7777}
7878
79- + (BOOL )unzipFileAtPath : (NSString *)path toDestination : (NSString *)destination overwrite : (BOOL )overwrite password : (nullable NSString *)password error : (NSError **)error delegate : (nullable id <SSZipArchiveDelegate >)delegate
79+ + (BOOL )unzipFileAtPath : (NSString *)path toDestination : (NSString *)destination overwrite : (BOOL )overwrite password : (nullable NSString *)password error : (NSError **)error delegate : (nullable id <RNZASSZipArchiveDelegate >)delegate
8080{
8181 return [self unzipFileAtPath: path toDestination: destination preserveAttributes: YES overwrite: overwrite password: password error: error delegate: delegate progressHandler: nil completionHandler: nil ];
8282}
@@ -105,7 +105,7 @@ + (BOOL)unzipFileAtPath:(NSString *)path
105105 overwrite : (BOOL )overwrite
106106 password : (nullable NSString *)password
107107 error : (NSError * *)error
108- delegate : (nullable id <SSZipArchiveDelegate >)delegate
108+ delegate : (nullable id <RNZASSZipArchiveDelegate >)delegate
109109{
110110 return [self unzipFileAtPath: path toDestination: destination preserveAttributes: preserveAttributes overwrite: overwrite password: password error: error delegate: delegate progressHandler: nil completionHandler: nil ];
111111}
@@ -116,7 +116,7 @@ + (BOOL)unzipFileAtPath:(NSString *)path
116116 overwrite : (BOOL )overwrite
117117 password : (NSString *)password
118118 error : (NSError **)error
119- delegate : (id <SSZipArchiveDelegate >)delegate
119+ delegate : (id <RNZASSZipArchiveDelegate >)delegate
120120 progressHandler : (void (^)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
121121 completionHandler : (void (^)(NSString *path, BOOL succeeded, NSError *error))completionHandler
122122{
@@ -125,7 +125,7 @@ + (BOOL)unzipFileAtPath:(NSString *)path
125125 if (zip == NULL )
126126 {
127127 NSDictionary *userInfo = @{NSLocalizedDescriptionKey : @" failed to open zip file" };
128- NSError *err = [NSError errorWithDomain: @" SSZipArchiveErrorDomain " code: -1 userInfo: userInfo];
128+ NSError *err = [NSError errorWithDomain: @" RNZASSZipArchiveErrorDomain " code: -1 userInfo: userInfo];
129129 if (error)
130130 {
131131 *error = err;
@@ -148,7 +148,7 @@ + (BOOL)unzipFileAtPath:(NSString *)path
148148 if (unzGoToFirstFile (zip) != UNZ_OK)
149149 {
150150 NSDictionary *userInfo = @{NSLocalizedDescriptionKey : @" failed to open first file in zip file" };
151- NSError *err = [NSError errorWithDomain: @" SSZipArchiveErrorDomain " code: -2 userInfo: userInfo];
151+ NSError *err = [NSError errorWithDomain: @" RNZASSZipArchiveErrorDomain " code: -2 userInfo: userInfo];
152152 if (error)
153153 {
154154 *error = err;
@@ -293,7 +293,7 @@ + (BOOL)unzipFileAtPath:(NSString *)path
293293 success = NO ;
294294 break ;
295295 }
296- NSLog (@" [SSZipArchive ] Error: %@ " , err.localizedDescription );
296+ NSLog (@" [RNZASSZipArchive ] Error: %@ " , err.localizedDescription );
297297 }
298298
299299 if ([fileManager fileExistsAtPath: fullPath] && !isDirectory && !overwrite) {
@@ -335,7 +335,7 @@ + (BOOL)unzipFileAtPath:(NSString *)path
335335 if (attr) {
336336 if ([fileManager setAttributes: attr ofItemAtPath: fullPath error: nil ] == NO ) {
337337 // Can't set attributes
338- NSLog (@" [SSZipArchive ] Failed to set attributes - whilst setting modification date" );
338+ NSLog (@" [RNZASSZipArchive ] Failed to set attributes - whilst setting modification date" );
339339 }
340340 }
341341 }
@@ -355,7 +355,7 @@ + (BOOL)unzipFileAtPath:(NSString *)path
355355 // Update attributes
356356 if ([fileManager setAttributes: attrs ofItemAtPath: fullPath error: nil ] == NO ) {
357357 // Unable to set the permissions attribute
358- NSLog (@" [SSZipArchive ] Failed to set attributes - whilst setting permissions" );
358+ NSLog (@" [RNZASSZipArchive ] Failed to set attributes - whilst setting permissions" );
359359 }
360360
361361#if !__has_feature(objc_arc)
@@ -434,10 +434,10 @@ + (BOOL)unzipFileAtPath:(NSString *)path
434434 NSError * err = nil ;
435435 for (NSDictionary * d in directoriesModificationDates) {
436436 if (![[NSFileManager defaultManager ] setAttributes: @{NSFileModificationDate : d[@" modDate" ]} ofItemAtPath: d[@" path" ] error: &err]) {
437- NSLog (@" [SSZipArchive ] Set attributes failed for directory: %@ ." , d[@" path" ]);
437+ NSLog (@" [RNZASSZipArchive ] Set attributes failed for directory: %@ ." , d[@" path" ]);
438438 }
439439 if (err) {
440- NSLog (@" [SSZipArchive ] Error setting directory file modification date attribute: %@ " ,err.localizedDescription );
440+ NSLog (@" [RNZASSZipArchive ] Error setting directory file modification date attribute: %@ " ,err.localizedDescription );
441441 }
442442 }
443443#if !__has_feature(objc_arc)
@@ -458,7 +458,7 @@ + (BOOL)unzipFileAtPath:(NSString *)path
458458 if (crc_ret == UNZ_CRCERROR)
459459 {
460460 NSDictionary *userInfo = @{NSLocalizedDescriptionKey : @" crc check failed for file" };
461- retErr = [NSError errorWithDomain: @" SSZipArchiveErrorDomain " code: -3 userInfo: userInfo];
461+ retErr = [NSError errorWithDomain: @" RNZASSZipArchiveErrorDomain " code: -3 userInfo: userInfo];
462462 }
463463
464464 if (error) {
@@ -485,20 +485,20 @@ + (BOOL)unzipFileAtPath:(NSString *)path
485485#pragma mark - Zipping
486486+ (BOOL )createZipFileAtPath : (NSString *)path withFilesAtPaths : (NSArray *)paths
487487{
488- return [SSZipArchive createZipFileAtPath: path withFilesAtPaths: paths withPassword: nil ];
488+ return [RNZASSZipArchive createZipFileAtPath: path withFilesAtPaths: paths withPassword: nil ];
489489}
490490+ (BOOL )createZipFileAtPath : (NSString *)path withContentsOfDirectory : (NSString *)directoryPath {
491- return [SSZipArchive createZipFileAtPath: path withContentsOfDirectory: directoryPath withPassword: nil ];
491+ return [RNZASSZipArchive createZipFileAtPath: path withContentsOfDirectory: directoryPath withPassword: nil ];
492492}
493493
494494+ (BOOL )createZipFileAtPath : (NSString *)path withContentsOfDirectory : (NSString *)directoryPath keepParentDirectory : (BOOL )keepParentDirectory {
495- return [SSZipArchive createZipFileAtPath: path withContentsOfDirectory: directoryPath keepParentDirectory: keepParentDirectory withPassword: nil ];
495+ return [RNZASSZipArchive createZipFileAtPath: path withContentsOfDirectory: directoryPath keepParentDirectory: keepParentDirectory withPassword: nil ];
496496}
497497
498498+ (BOOL )createZipFileAtPath : (NSString *)path withFilesAtPaths : (NSArray *)paths withPassword : (NSString *)password
499499{
500500 BOOL success = NO ;
501- SSZipArchive *zipArchive = [[SSZipArchive alloc ] initWithPath: path];
501+ RNZASSZipArchive *zipArchive = [[RNZASSZipArchive alloc ] initWithPath: path];
502502 if ([zipArchive open ]) {
503503 for (NSString *filePath in paths) {
504504 [zipArchive writeFile: filePath withPassword: password];
@@ -522,7 +522,7 @@ + (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *
522522 BOOL success = NO ;
523523
524524 NSFileManager *fileManager = nil ;
525- SSZipArchive *zipArchive = [[SSZipArchive alloc ] initWithPath: path];
525+ RNZASSZipArchive *zipArchive = [[RNZASSZipArchive alloc ] initWithPath: path];
526526
527527 if ([zipArchive open ]) {
528528 // use a local filemanager (queue/thread compatibility)
@@ -745,7 +745,7 @@ - (BOOL)writeData:(NSData *)data filename:(nullable NSString *)filename withPass
745745
746746- (BOOL )close
747747{
748- NSAssert ((_zip != NULL ), @"[SSZipArchive ] Attempting to close an archive which was never opened");
748+ NSAssert ((_zip != NULL ), @"[RNZASSZipArchive ] Attempting to close an archive which was never opened");
749749 zipClose (_zip, NULL );
750750 return YES ;
751751}
@@ -795,7 +795,7 @@ + (NSDate *)_dateWithMSDOSFormat:(UInt32)msdosDateTime
795795
796796 NSDateComponents *components = [[NSDateComponents alloc ] init ];
797797
798- NSAssert (0xFFFFFFFF == (kYearMask | kMonthMask | kDayMask | kHourMask | kMinuteMask | kSecondMask ), @"[SSZipArchive ] MSDOS date masks don't add up");
798+ NSAssert (0xFFFFFFFF == (kYearMask | kMonthMask | kDayMask | kHourMask | kMinuteMask | kSecondMask ), @"[RNZASSZipArchive ] MSDOS date masks don't add up");
799799
800800 [components setYear: 1980 + ((msdosDateTime & kYearMask ) >> 25 )];
801801 [components setMonth: (msdosDateTime & kMonthMask ) >> 21 ];
@@ -813,4 +813,4 @@ + (NSDate *)_dateWithMSDOSFormat:(UInt32)msdosDateTime
813813 return date;
814814}
815815
816- @end
816+ @end
0 commit comments