Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing ZipUnarchiver.

  • Loading branch information...
commit e00802579c3e191c6bbe6a83fa909674e1864099 1 parent 8764161
@pk authored
Showing with 14 additions and 14 deletions.
  1. +1 −1  Foundation/PKZipUnarchiver.h
  2. +13 −13 Foundation/PKZipUnarchiver.m
View
2  Foundation/PKZipUnarchiver.h
@@ -12,7 +12,7 @@
#import "ZipReadStream.h"
-#ifndef
+#ifndef PK_ZIPUNARCHIVER_BUFFER_SIZE
#define PK_ZIPUNARCHIVER_BUFFER_SIZE (1024 * 32)
#endif
View
26 Foundation/PKZipUnarchiver.m
@@ -9,7 +9,6 @@
#import "PKZipUnarchiver.h"
@interface PKZipUnarchiver ()
-@property (nonatomic, assign, readonly) NSUInteger totalUncompressedSize;
@property (nonatomic, copy, readonly) NSString *zipPath;
@end
@@ -45,25 +44,26 @@ - (id)initWithZipAtPath:(NSString *)aPath {
- (BOOL)unzipTo:(NSString *)aDestination error:(NSError **)outError {
ZipFile *zipFile = [[ZipFile alloc] initWithFileName:_zipPath mode:ZipFileModeUnzip];
- if (![zipFile goToFirstFileInZip:&outError]) {
- return NO;
- }
-
NSUInteger totalUncompressedSize = 0;
+ NSArray *zipFileInformation = [zipFile containedFiles];
if ([self.delegate respondsToSelector:@selector(didUncompressBytes:total:)]) {
- NSArray *zipFileInformation = [zipFile containedFiles];
ZipFileInfo *fileInfo;
for (fileInfo in zipFileInformation) {
totalUncompressedSize += fileInfo.length;
+ LogDebug(@"File:%@ of size %d",fileInfo.name,fileInfo.length);
}
}
-
+
+ if (![zipFile goToFirstFileInZip:outError]) {
+ return NO;
+ }
+
BOOL isDirectory;
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSString *currentFilePath;
NSUInteger currentFileIndex = 0;
do {
- ZipReadStream *file = [zipFile readCurrentFileInZip:&outError];
+ ZipReadStream *file = [zipFile readCurrentFileInZip:outError];
ZipFileInfo *fileInfo = [zipFileInformation objectAtIndex:currentFileIndex];
isDirectory = [fileInfo.name hasSuffix:@"/"];
currentFilePath = [aDestination stringByAppendingPathComponent:fileInfo.name];
@@ -72,7 +72,7 @@ - (BOOL)unzipTo:(NSString *)aDestination error:(NSError **)outError {
[fileManager createDirectoryAtPath:currentFilePath
withIntermediateDirectories:YES
attributes:nil
- error:&outError];
+ error:outError];
} else {
[fileManager createFileAtPath:currentFilePath
contents:nil
@@ -80,8 +80,8 @@ - (BOOL)unzipTo:(NSString *)aDestination error:(NSError **)outError {
NSUInteger bytesRead = 0;
NSFileHandle *fileHandle = [NSFileHandle fileHandleForWritingAtPath:currentFilePath];
- NSMutableData *buffer = [[NSMutableData alloc] initWithLength:BUFFER_SIZE];
- while ((bytesRead = [file readDataWithBuffer:buffer error:&outError]) != 0) {
+ NSMutableData *buffer = [[NSMutableData alloc] initWithLength:PK_ZIPUNARCHIVER_BUFFER_SIZE];
+ while ((bytesRead = [file readDataWithBuffer:buffer error:outError]) != 0) {
[fileHandle writeData:buffer];
if ([self.delegate respondsToSelector:@selector(didUncompressBytes:total:)]) {
[self.delegate didUncompressBytes:bytesRead total:totalUncompressedSize];
@@ -90,9 +90,9 @@ - (BOOL)unzipTo:(NSString *)aDestination error:(NSError **)outError {
[buffer release]; buffer = nil;
[fileHandle closeFile];
}
- [file finishedReadingWithError:&outError];
+ [file finishedReadingWithError:outError];
currentFileIndex++;
- } while([zipFile goToNextFileInZip:&outError]);
+ } while([zipFile goToNextFileInZip:outError]);
[fileManager release];
[zipFile close];
Please sign in to comment.
Something went wrong with that request. Please try again.