Overview
Comment: | utils/ofzip: Make use of generics |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
c3581d80a255c3f5d488006b24ee00f6 |
User & Date: | js on 2015-06-28 17:02:09 |
Other Links: | manifest | tags |
Context
2015-06-28
| ||
17:09 | utils/ofzip: Recompose paths check-in: 0d49a2e6a7 user: js tags: trunk | |
17:02 | utils/ofzip: Make use of generics check-in: c3581d80a2 user: js tags: trunk | |
16:39 | tests: Use __VA_ARGS__ for TEST() and clean up check-in: 07e630588d user: js tags: trunk | |
Changes
Modified utils/ofzip/OFZIP.m from [d4981a261c] to [5f988826d6].
︙ | ︙ | |||
17 18 19 20 21 22 23 | #include "config.h" #include <string.h> #import "OFApplication.h" #import "OFArray.h" #import "OFDate.h" | < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include "config.h" #include <string.h> #import "OFApplication.h" #import "OFArray.h" #import "OFDate.h" #import "OFFile.h" #import "OFOptionsParser.h" #import "OFSet.h" #import "OFStdIOStream.h" #import "OFZIPArchive.h" #import "OFZIPArchiveEntry.h" |
︙ | ︙ | |||
48 49 50 51 52 53 54 | { int_fast8_t _override, _outputLevel; int _exitStatus; } - (OFZIPArchive*)openArchiveWithPath: (OFString*)path; - (void)listFilesInArchive: (OFZIPArchive*)archive; | | | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | { int_fast8_t _override, _outputLevel; int _exitStatus; } - (OFZIPArchive*)openArchiveWithPath: (OFString*)path; - (void)listFilesInArchive: (OFZIPArchive*)archive; - (void)extractFiles: (OFArray OF_GENERIC(OFString*)*)files fromArchive: (OFZIPArchive*)archive; @end OF_APPLICATION_DELEGATE(OFZIP) static void help(OFStream *stream, bool full, int status) |
︙ | ︙ | |||
106 107 108 109 110 111 112 | @implementation OFZIP - (void)applicationDidFinishLaunching { OFOptionsParser *optionsParser = [OFOptionsParser parserWithOptions: @"fhlnqvx"]; of_unichar_t option, mode = '\0'; | | < | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | @implementation OFZIP - (void)applicationDidFinishLaunching { OFOptionsParser *optionsParser = [OFOptionsParser parserWithOptions: @"fhlnqvx"]; of_unichar_t option, mode = '\0'; OFArray OF_GENERIC(OFString*) *remainingArguments, *files; OFZIPArchive *archive; while ((option = [optionsParser nextOption]) != '\0') { switch (option) { case 'f': if (_override < 0) mutuallyExclusiveError('f', 'n'); |
︙ | ︙ | |||
224 225 226 227 228 229 230 | } return archive; } - (void)listFilesInArchive: (OFZIPArchive*)archive { | | > > | 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | } return archive; } - (void)listFilesInArchive: (OFZIPArchive*)archive { OFEnumerator OF_GENERIC(OFZIPArchiveEntry*) *enumerator; OFZIPArchiveEntry *entry; enumerator = [[archive entries] objectEnumerator]; while ((entry = [enumerator nextObject]) != nil) { void *pool = objc_autoreleasePoolPush(); [of_stdout writeLine: [entry fileName]]; if (_outputLevel >= 1) { |
︙ | ︙ | |||
277 278 279 280 281 282 283 | [entry fileComment]]; } objc_autoreleasePoolPop(pool); } } | | | > > > | | > | | | 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | [entry fileComment]]; } objc_autoreleasePoolPop(pool); } } - (void)extractFiles: (OFArray OF_GENERIC(OFString*)*)files fromArchive: (OFZIPArchive*)archive { OFEnumerator OF_GENERIC(OFZIPArchiveEntry*) *entryEnumerator; OFZIPArchiveEntry *entry; bool all; OFMutableSet OF_GENERIC(OFString*) *missing; all = ([files count] == 0); missing = [OFMutableSet setWithArray: files]; entryEnumerator = [[archive entries] objectEnumerator]; while ((entry = [entryEnumerator nextObject]) != nil) { void *pool = objc_autoreleasePoolPush(); OFString *fileName = [entry fileName]; OFString *outFileName = [fileName stringByStandardizingPath]; OFEnumerator OF_GENERIC(OFString*) *componentEnumerator; OFString *component, *directory; OFStream *stream; OFFile *output; char buffer[BUFFER_SIZE]; uint64_t written = 0, size = [entry uncompressedSize]; int_fast8_t percent = -1, newPercent; |
︙ | ︙ | |||
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | fileName]; outer_loop_end: objc_autoreleasePoolPop(pool); } if ([missing count] > 0) { OFString *file; enumerator = [missing objectEnumerator]; while ((file = [enumerator nextObject]) != nil) [of_stderr writeFormat: @"File %@ is not in the archive!\n", file]; _exitStatus = 1; } } @end | > | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | fileName]; outer_loop_end: objc_autoreleasePoolPop(pool); } if ([missing count] > 0) { OFEnumerator OF_GENERIC(OFString*) *enumerator; OFString *file; enumerator = [missing objectEnumerator]; while ((file = [enumerator nextObject]) != nil) [of_stderr writeFormat: @"File %@ is not in the archive!\n", file]; _exitStatus = 1; } } @end |