Differences From Artifact [1e1f67001f]:
- File utils/ofzip/OFZIP.m — part of check-in [0d49a2e6a7] at 2015-06-28 17:09:41 on branch trunk — utils/ofzip: Recompose paths (user: js, size: 11779) [annotate] [blame] [check-ins using]
To Artifact [96f7f2e4d5]:
- File
utils/ofzip/OFZIP.m
— part of check-in
[f3c452dfef]
at
2015-08-22 10:57:14
on branch trunk
— Move file management to its own class
This makes it possible to add support for delegates for file management
operations and on top makes it easier to add support for file management
operations on URLs. (user: js, size: 11936) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #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" #import "OFCreateDirectoryFailedException.h" | > | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #include <string.h> #import "OFApplication.h" #import "OFArray.h" #import "OFDate.h" #import "OFFile.h" #import "OFFileManager.h" #import "OFOptionsParser.h" #import "OFSet.h" #import "OFStdIOStream.h" #import "OFZIPArchive.h" #import "OFZIPArchiveEntry.h" #import "OFCreateDirectoryFailedException.h" |
︙ | ︙ | |||
93 94 95 96 97 98 99 | if (([entry versionMadeBy] >> 8) == OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_UNIX) { uint32_t mode = [entry versionSpecificAttributes] >> 16; /* Only allow modes that are safe */ mode &= (S_IRWXU | S_IRWXG | S_IRWXO); | > | | | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | if (([entry versionMadeBy] >> 8) == OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_UNIX) { uint32_t mode = [entry versionSpecificAttributes] >> 16; /* Only allow modes that are safe */ mode &= (S_IRWXU | S_IRWXG | S_IRWXO); [[OFFileManager defaultManager] changePermissionsOfItemAtPath: path permissions: mode]; } #endif } @implementation OFZIP - (void)applicationDidFinishLaunching { |
︙ | ︙ | |||
280 281 282 283 284 285 286 287 288 289 290 291 292 293 | 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]; | > | 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | objc_autoreleasePoolPop(pool); } } - (void)extractFiles: (OFArray OF_GENERIC(OFString*)*)files fromArchive: (OFZIPArchive*)archive { OFFileManager *fileManager = [OFFileManager defaultManager]; OFEnumerator OF_GENERIC(OFZIPArchiveEntry*) *entryEnumerator; OFZIPArchiveEntry *entry; bool all; OFMutableSet OF_GENERIC(OFString*) *missing; all = ([files count] == 0); missing = [OFMutableSet setWithArray: files]; |
︙ | ︙ | |||
337 338 339 340 341 342 343 | } outFileName = [OFString pathWithComponents: pathComponents]; if (_outputLevel >= 0) [of_stdout writeFormat: @"Extracting %@...", fileName]; if ([fileName hasSuffix: @"/"]) { | | | | | | | > | 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | } outFileName = [OFString pathWithComponents: pathComponents]; if (_outputLevel >= 0) [of_stdout writeFormat: @"Extracting %@...", fileName]; if ([fileName hasSuffix: @"/"]) { [fileManager createDirectoryAtPath: outFileName createParents: true]; setPermissions(outFileName, entry); if (_outputLevel >= 0) [of_stdout writeLine: @" done"]; goto outer_loop_end; } directory = [outFileName stringByDeletingLastPathComponent]; if (![fileManager directoryExistsAtPath: directory]) [fileManager createDirectoryAtPath: directory createParents: true]; if ([fileManager fileExistsAtPath: outFileName] && _override != 1) { OFString *line; if (_override == -1) { if (_outputLevel >= 0) [of_stdout writeLine: @" skipped"]; goto outer_loop_end; |
︙ | ︙ |