Browse files

Fixing rewinding to the top of the ZIP file when we get the ZIP

information from the file.
  • Loading branch information...
1 parent 221b638 commit 5cb8f02cb593dba6c5483bcc68a2f2505d9a2e45 @pk committed Sep 23, 2011
Showing with 6 additions and 3 deletions.
  1. +6 −3 Foundation/PKZipUnarchiver.m
View
9 Foundation/PKZipUnarchiver.m
@@ -63,6 +63,7 @@ - (BOOL)unzipTo:(NSString *)aDestination error:(NSError **)outError {
NSString *currentFilePath;
NSUInteger currentFileIndex = 0;
NSArray *zipFilesInfo = [self zipFilesInformation];
+
do {
ZipReadStream *file = [self.zipFile readCurrentFileInZip:outError];
ZipFileInfo *fileInfo = [zipFilesInfo objectAtIndex:currentFileIndex];
@@ -120,10 +121,12 @@ - (NSUInteger)uncompressedSize {
#pragma mark - Private methods
- (NSArray *)zipFilesInformation {
- if (_zipFilesInformation != nil) {
- return _zipFilesInformation;
+ if (_zipFilesInformation == nil) {
+ _zipFilesInformation = [[self.zipFile containedFiles] retain];
+ [self.zipFile goToFirstFileInZip:NULL]; // Necessary because contained
+ // files doesn't rever pointer
+ // in the zip to the first file.
}
- _zipFilesInformation = [[self.zipFile containedFiles] retain];
return _zipFilesInformation;
}

0 comments on commit 5cb8f02

Please sign in to comment.