Differences From Artifact [0ee3c33822]:
- File
src/OFFile.m
— part of check-in
[169f06e1ec]
at
2013-12-09 22:19:30
on branch trunk
— Add +[OFFile copyItemAtPath:toPath:].
This replaces +[OFFile copyFileAtPath:toPath:]. (user: js, size: 20239) [annotate] [blame] [check-ins using]
To Artifact [952a84375d]:
- File
src/OFFile.m
— part of check-in
[aefb143a8d]
at
2013-12-09 23:24:45
on branch trunk
— +[OFFile copyFileAtPath:toPath:]: Win32 stuff.
Also slightly decreases memory footprint. (user: js, size: 20432) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 | } #endif + (void)copyItemAtPath: (OFString*)source toPath: (OFString*)destination { void *pool; struct stat s; if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); if ([self directoryExistsAtPath: destination]) { OFArray *components = [OFArray arrayWithObjects: destination, [source lastPathComponent], nil]; destination = [OFString pathWithComponents: components]; } if (lstat([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE], &s)) @throw [OFCopyItemFailedException exceptionWithSourcePath: source destinationPath: destination]; if (S_ISREG(s.st_mode)) { #ifdef OF_HAVE_CHMOD bool override = [self fileExistsAtPath: destination]; | > > > > > > > > | 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 | } #endif + (void)copyItemAtPath: (OFString*)source toPath: (OFString*)destination { void *pool; #ifndef _WIN32 struct stat s; #else struct _stat s; #endif if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); if ([self directoryExistsAtPath: destination]) { OFArray *components = [OFArray arrayWithObjects: destination, [source lastPathComponent], nil]; destination = [OFString pathWithComponents: components]; } #ifndef _WIN32 if (lstat([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE], &s)) #else if (_wstat([source UTF16String], &s)) #endif @throw [OFCopyItemFailedException exceptionWithSourcePath: source destinationPath: destination]; if (S_ISREG(s.st_mode)) { #ifdef OF_HAVE_CHMOD bool override = [self fileExistsAtPath: destination]; |
︙ | ︙ | |||
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 | @throw [OFCopyItemFailedException exceptionWithSourcePath: source destinationPath: destination]; } enumerator = [contents objectEnumerator]; while ((item = [enumerator nextObject]) != nil) { OFArray *components; OFString *sourcePath, *destinationPath; components = [OFArray arrayWithObjects: source, item, nil]; sourcePath = [OFString pathWithComponents: components]; components = [OFArray arrayWithObjects: destination, item, nil]; destinationPath = [OFString pathWithComponents: components]; [OFFile copyItemAtPath: sourcePath toPath: destinationPath]; } #ifdef OF_HAVE_SYMLINK } else if (S_ISLNK(s.st_mode)) { @try { if ([OFFile symbolicLinkExistsAtPath: destination] || [OFFile fileExistsAtPath: destination]) [OFFile removeItemAtPath: destination]; | > > > | 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 | @throw [OFCopyItemFailedException exceptionWithSourcePath: source destinationPath: destination]; } enumerator = [contents objectEnumerator]; while ((item = [enumerator nextObject]) != nil) { void *pool2 = objc_autoreleasePoolPush(); OFArray *components; OFString *sourcePath, *destinationPath; components = [OFArray arrayWithObjects: source, item, nil]; sourcePath = [OFString pathWithComponents: components]; components = [OFArray arrayWithObjects: destination, item, nil]; destinationPath = [OFString pathWithComponents: components]; [OFFile copyItemAtPath: sourcePath toPath: destinationPath]; objc_autoreleasePoolPop(pool2); } #ifdef OF_HAVE_SYMLINK } else if (S_ISLNK(s.st_mode)) { @try { if ([OFFile symbolicLinkExistsAtPath: destination] || [OFFile fileExistsAtPath: destination]) [OFFile removeItemAtPath: destination]; |
︙ | ︙ |