Differences From Artifact [737527b063]:
- File src/OFFileManager.m — part of check-in [1ba08eebc5] at 2015-10-19 22:15:13 on branch trunk — Add platform.h & make platform defines consistent (user: js, size: 21437) [annotate] [blame] [check-ins using]
To Artifact [a3021efc2a]:
- File
src/OFFileManager.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: 20985) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
246 247 248 249 250 251 252 | exceptionWithPath: path errNo: errno]; } - (void)createDirectoryAtPath: (OFString*)path createParents: (bool)createParents { | < < | < < < | < < | | < < | 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | exceptionWithPath: path errNo: errno]; } - (void)createDirectoryAtPath: (OFString*)path createParents: (bool)createParents { OFString *currentPath = nil; if (!createParents) { [self createDirectoryAtPath: path]; return; } if (path == nil) @throw [OFInvalidArgumentException exception]; for (OFString *component in [path pathComponents]) { void *pool = objc_autoreleasePoolPush(); if (currentPath != nil) currentPath = [currentPath stringByAppendingPathComponent: component]; else currentPath = component; if ([currentPath length] > 0 && ![self directoryExistsAtPath: currentPath]) [self createDirectoryAtPath: currentPath]; [currentPath retain]; objc_autoreleasePoolPop(pool); [currentPath autorelease]; } } - (OFArray*)contentsOfDirectoryAtPath: (OFString*)path { OFMutableArray *files; #ifndef OF_WINDOWS of_string_encoding_t encoding; |
︙ | ︙ | |||
591 592 593 594 595 596 597 | @throw [OFCopyItemFailedException exceptionWithSourcePath: source destinationPath: destination errNo: errno]; if (S_ISDIR(s.st_mode)) { OFArray *contents; | < < | 582 583 584 585 586 587 588 589 590 591 592 593 594 595 | @throw [OFCopyItemFailedException exceptionWithSourcePath: source destinationPath: destination errNo: errno]; if (S_ISDIR(s.st_mode)) { OFArray *contents; @try { [self createDirectoryAtPath: destination]; #ifdef OF_HAVE_CHMOD [self changePermissionsOfItemAtPath: destination permissions: s.st_mode]; #endif |
︙ | ︙ | |||
618 619 620 621 622 623 624 | exceptionWithSourcePath: source destinationPath: destination errNo: [e errNo]]; @throw e; } | | < | 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 | exceptionWithSourcePath: source destinationPath: destination errNo: [e errNo]]; @throw e; } for (OFString *item in contents) { void *pool2 = objc_autoreleasePoolPush(); OFString *sourcePath, *destinationPath; sourcePath = [source stringByAppendingPathComponent: item]; destinationPath = [destination stringByAppendingPathComponent: item]; |
︙ | ︙ | |||
788 789 790 791 792 793 794 | if (of_lstat(path, &s) != 0) @throw [OFRemoveItemFailedException exceptionWithPath: path errNo: errno]; if (S_ISDIR(s.st_mode)) { OFArray *contents; | < < | < | 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 | if (of_lstat(path, &s) != 0) @throw [OFRemoveItemFailedException exceptionWithPath: path errNo: errno]; if (S_ISDIR(s.st_mode)) { OFArray *contents; @try { contents = [self contentsOfDirectoryAtPath: path]; } @catch (id e) { /* * Only convert exceptions to * OFRemoveItemFailedException that have an errNo * property. This covers all I/O related exceptions * from the operations used to remove an item, all * others should be left as is. */ if ([e respondsToSelector: @selector(errNo)]) @throw [OFRemoveItemFailedException exceptionWithPath: path errNo: [e errNo]]; @throw e; } for (OFString *item in contents) { void *pool2 = objc_autoreleasePoolPush(); [self removeItemAtPath: [path stringByAppendingPathComponent: item]]; objc_autoreleasePoolPop(pool2); } |
︙ | ︙ |