Differences From Artifact [726f0b6ba9]:
- File src/OFFile.m — part of check-in [242fd56445] at 2013-12-11 22:26:02 on branch trunk — +[{copy,rename}ItemAtPath...]: Require full path. (user: js, size: 20862) [annotate] [blame] [check-ins using]
To Artifact [95c6f11fb5]:
- File
src/OFFile.m
— part of check-in
[260391fc1c]
at
2013-12-11 23:53:07
on branch trunk
— Add +[OFFile moveItemAtPath:toPath:].
This replaces +[OFFile renameItemAtPath:toPath:] and supports moving
files to different logical devices. (user: js, size: 21737) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
63 64 65 66 67 68 69 70 71 72 73 | #import "OFCopyItemFailedException.h" #import "OFCreateDirectoryFailedException.h" #import "OFCreateSymbolicLinkFailedException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFLinkFailedException.h" #import "OFLockFailedException.h" #import "OFOpenFileFailedException.h" #import "OFOutOfMemoryException.h" #import "OFReadFailedException.h" #import "OFRemoveItemFailedException.h" | > < | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | #import "OFCopyItemFailedException.h" #import "OFCreateDirectoryFailedException.h" #import "OFCreateSymbolicLinkFailedException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFLinkFailedException.h" #import "OFLockFailedException.h" #import "OFMoveItemFailedException.h" #import "OFOpenFileFailedException.h" #import "OFOutOfMemoryException.h" #import "OFReadFailedException.h" #import "OFRemoveItemFailedException.h" #import "OFSeekFailedException.h" #import "OFUnlockFailedException.h" #import "OFWriteFailedException.h" #import "autorelease.h" #import "macros.h" |
︙ | ︙ | |||
661 662 663 664 665 666 667 | @throw [OFCopyItemFailedException exceptionWithSourcePath: source destinationPath: destination]; objc_autoreleasePoolPop(pool); } | | | > > > > > > > > > > > > > > > > > | | > | | | > > > > > > > > > > > > > > > > > > > | 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 | @throw [OFCopyItemFailedException exceptionWithSourcePath: source destinationPath: destination]; objc_autoreleasePoolPop(pool); } + (void)moveItemAtPath: (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(); #ifndef _WIN32 if (lstat([destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE], &s) == 0) { #else if (_wstat([destination UTF16String], &s) == 0) { #endif errno = EEXIST; @throw [OFCopyItemFailedException exceptionWithSourcePath: source destinationPath: destination]; } #ifndef _WIN32 if (rename([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE], [destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE])) { #else if (_wrename([source UTF16String], [destination UTF16String])) { #endif if (errno != EXDEV) @throw [OFMoveItemFailedException exceptionWithSourcePath: source destinationPath: destination]; @try { [OFFile copyItemAtPath: source toPath: destination]; } @catch (OFCopyItemFailedException *e) { [OFFile removeItemAtPath: destination]; @throw [OFMoveItemFailedException exceptionWithSourcePath: source destinationPath: destination]; } @try { [OFFile removeItemAtPath: source]; } @catch (OFRemoveItemFailedException *e) { @throw [OFMoveItemFailedException exceptionWithSourcePath: source destinationPath: destination]; } } objc_autoreleasePoolPop(pool); } + (void)removeItemAtPath: (OFString*)path { void *pool; |
︙ | ︙ |