Differences From Artifact [6492307736]:
- File
utils/ofzip/OFZIP.m
— part of check-in
[bfa913aebe]
at
2015-11-28 18:56:19
on branch trunk
— OFOptionsParser: Reworked API
The new API allows long options and requires less manual parsing. (user: js, size: 12738) [annotate] [blame] [check-ins using]
To Artifact [d383d3b508]:
- File
utils/ofzip/OFZIP.m
— part of check-in
[6b13727ce0]
at
2015-11-29 14:02:11
on branch trunk
— Make use of fast enumeration
Now that we require GCC >= 4.6 anyway, there's no more reason to not use
it anymore. (user: js, size: 12165) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
250 251 252 253 254 255 256 | } return archive; } - (void)listFilesInArchive: (OFZIPArchive*)archive { | < | < < < < | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | } return archive; } - (void)listFilesInArchive: (OFZIPArchive*)archive { for (OFZIPArchiveEntry *entry in [archive entries]) { void *pool = objc_autoreleasePoolPush(); [of_stdout writeLine: [entry fileName]]; if (_outputLevel >= 1) { OFString *date = [[entry modificationDate] localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"]; |
︙ | ︙ | |||
309 310 311 312 313 314 315 | } } - (void)extractFiles: (OFArray OF_GENERIC(OFString*)*)files fromArchive: (OFZIPArchive*)archive { OFFileManager *fileManager = [OFFileManager defaultManager]; | < < | | < < | | < < | | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | } } - (void)extractFiles: (OFArray OF_GENERIC(OFString*)*)files fromArchive: (OFZIPArchive*)archive { OFFileManager *fileManager = [OFFileManager defaultManager]; bool all = ([files count] == 0); OFMutableSet OF_GENERIC(OFString*) *missing = [OFMutableSet setWithArray: files]; for (OFZIPArchiveEntry *entry in [archive entries]) { void *pool = objc_autoreleasePoolPush(); OFString *fileName = [entry fileName]; OFString *outFileName = [fileName stringByStandardizingPath]; OFArray OF_GENERIC(OFString*) *pathComponents; OFString *directory; OFStream *stream; OFFile *output; char buffer[BUFFER_SIZE]; uint64_t written = 0, size = [entry uncompressedSize]; int_fast8_t percent = -1, newPercent; if (!all && ![files containsObject: fileName]) |
︙ | ︙ | |||
350 351 352 353 354 355 356 | fileName]; _exitStatus = 1; goto outer_loop_end; } pathComponents = [outFileName pathComponents]; | | < | 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | fileName]; _exitStatus = 1; goto outer_loop_end; } pathComponents = [outFileName pathComponents]; for (OFString *component in pathComponents) { if ([component isEqual: OF_PATH_PARENT_DIRECTORY]) { [of_stderr writeFormat: @"Refusing to extract %@!\n", fileName]; _exitStatus = 1; goto outer_loop_end; } |
︙ | ︙ | |||
476 477 478 479 480 481 482 | fileName]; outer_loop_end: objc_autoreleasePoolPop(pool); } if ([missing count] > 0) { | < | < < < | 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 | fileName]; outer_loop_end: objc_autoreleasePoolPop(pool); } if ([missing count] > 0) { for (OFString *file in missing) [of_stderr writeFormat: @"File %@ is not in the archive!\n", file]; _exitStatus = 1; } } @end |