Differences From Artifact [b923b772b8]:
- File
utils/objfw-unzip.m
— part of check-in
[0964e7d687]
at
2013-10-20 11:30:22
on branch trunk
— Add objfw-unzip.
This a small tool to extract ZIP files, using OFZIPArchive.
The idea is that as ObjFW contains a complete ZIP implementation anyway,
it makes sense to add those few extra lines of code to have a very small
tool using ObjFW's ZIP implementation. (user: js, size: 3571) [annotate] [blame] [check-ins using]
To Artifact [b335e42d82]:
- File utils/objfw-unzip.m — part of check-in [64f72315cd] at 2013-11-06 21:11:23 on branch trunk — objfw-unzip: Add "never override" mode. (user: js, size: 3770) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
35 36 37 38 39 40 41 | [OFApplication terminate]; } - (void)extractAllFilesFromArchive: (OFZIPArchive*)archive { OFEnumerator *enumerator = [[archive entries] objectEnumerator]; OFZIPArchiveEntry *entry; | | | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | [OFApplication terminate]; } - (void)extractAllFilesFromArchive: (OFZIPArchive*)archive { OFEnumerator *enumerator = [[archive entries] objectEnumerator]; OFZIPArchiveEntry *entry; int_fast8_t override = 0; while ((entry = [enumerator nextObject]) != nil) { void *pool = objc_autoreleasePoolPush(); OFString *fileName = [entry fileName]; OFString *outFileName = [fileName stringByStandardizingPath]; OFEnumerator *componentEnumerator; OFString *component, *directory; |
︙ | ︙ | |||
84 85 86 87 88 89 90 | } directory = [outFileName stringByDeletingLastPathComponent]; if (![OFFile directoryExistsAtPath: directory]) [OFFile createDirectoryAtPath: directory createParents: true]; | | > > > > > | | > | > > > > > < < < | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | } directory = [outFileName stringByDeletingLastPathComponent]; if (![OFFile directoryExistsAtPath: directory]) [OFFile createDirectoryAtPath: directory createParents: true]; if ([OFFile fileExistsAtPath: outFileName] && override != 1) { OFString *line; if (override == -1) { [of_stdout writeLine: @" skipped"]; continue; } do { [of_stderr writeFormat: @"\rOverride %@? [ynAN] ", fileName]; line = [of_stdin readLine]; } while (![line isEqual: @"y"] && ![line isEqual: @"n"] && ![line isEqual: @"N"] && ![line isEqual: @"A"]); if ([line isEqual: @"A"]) override = 1; else if ([line isEqual: @"N"]) override = -1; if ([line isEqual: @"n"] || [line isEqual: @"N"]) { [of_stdout writeFormat: @"Skipping %@...\n", fileName]; continue; } [of_stdout writeFormat: @"Extracting %@...", fileName]; } stream = [archive streamForReadingFile: fileName]; output = [OFFile fileWithPath: outFileName mode: @"w"]; |
︙ | ︙ |