Open jjxtra opened 7 years ago
Using this code to create an archive, I'm unable to open in Windows or MAC.
ZZArchive* archive = [[ZZArchive alloc] initWithURL:url options:@{ZZOpenOptionsCreateIfMissingKey : @YES} error:&error]; if (error == nil) { NSMutableArray* entries = [NSMutableArray array]; for (NSURL* fileURL in fileURLs) { NSURL* fileURLCopy = fileURL; fileAttributes = [fm attributesOfItemAtPath:fileURL.path error:&error]; fileSumSize += fileAttributes.fileSize; NSString* subFile = [fileURL.path substringFromIndex:root.length]; NSString* subDir = [subFile stringByDeletingLastPathComponent]; if (subDir.length > 0 && ![dirs containsObject:subDir]) { [dirs addObject:subDir]; ZZArchiveEntry* dirEntry = [ZZArchiveEntry archiveEntryWithDirectoryName:subDir]; [entries addObject:dirEntry]; } ZZArchiveEntry* entry = [ZZArchiveEntry archiveEntryWithFileName:subFile compress:NO streamBlock:^(NSOutputStream* output, NSError** _error) { uint8_t buffer[8192]; NSInputStream* input = [NSInputStream inputStreamWithFileAtPath:fileURLCopy.path]; NSInteger count; [input open]; while ((count = [input read:buffer maxLength:8192]) > 0) { NSInteger written = 0; while (written < count) { written += [output write:buffer + written maxLength:count - written]; bytesWritten += written; } } [input close]; [self updateProgress:++filesWritten total:fileURLs.count]; return YES; }]; [entries addObject:entry]; } if (error == nil) { [archive updateEntries:entries error:&error]; }
From inspection, I don't see any issues with the code.
Please supply a self-contained Xcode project with sample files and the minimal code needed to show the problem.
Using this code to create an archive, I'm unable to open in Windows or MAC.