ObjFW  Check-in [242fd56445]

Overview
Comment:+[{copy,rename}ItemAtPath...]: Require full path.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 242fd56445e6243904747aab8a15480024f65d49cfee9c2b968385a2e57f1130
User & Date: js on 2013-12-11 22:26:02
Other Links: manifest | tags
Context
2013-12-11
23:53
Add +[OFFile moveItemAtPath:toPath:]. check-in: 260391fc1c user: js tags: trunk
22:26
+[{copy,rename}ItemAtPath...]: Require full path. check-in: 242fd56445 user: js tags: trunk
22:19
+[copyFileAtPath:toPath:]: Never override items. check-in: ba57490ba6 user: js tags: trunk
Changes

Modified src/OFFile.h from [4cbfda525d] to [78bb0798b0].

175
176
177
178
179
180
181



182
183
184
185
186
187
188
189
190
191
192
193
194



195
196
197
198
199
200
201
+ (void)changeOwnerOfItemAtPath: (OFString*)path
			  owner: (OFString*)owner
			  group: (OFString*)group;
#endif

/*!
 * @brief Copies a file, directory or symlink (if supported by the OS).



 *
 * If an item already exists, the copy operation fails. This is also the case
 * if a directory is copied and an item already exists in the destination
 * directory.
 *
 * @param source The file, directory or symlink to copy
 * @param destination The destination path
 */
+ (void)copyItemAtPath: (OFString*)source
		toPath: (OFString*)destination;

/*!
 * @brief Renames an item.



 *
 * @param source The item to rename
 * @param destination The new name for the item
 */
+ (void)renameItemAtPath: (OFString*)source
		  toPath: (OFString*)destination;








>
>
>













>
>
>







175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
+ (void)changeOwnerOfItemAtPath: (OFString*)path
			  owner: (OFString*)owner
			  group: (OFString*)group;
#endif

/*!
 * @brief Copies a file, directory or symlink (if supported by the OS).
 *
 * The destination path must be a full path, which means it must include the
 * name of the item.
 *
 * If an item already exists, the copy operation fails. This is also the case
 * if a directory is copied and an item already exists in the destination
 * directory.
 *
 * @param source The file, directory or symlink to copy
 * @param destination The destination path
 */
+ (void)copyItemAtPath: (OFString*)source
		toPath: (OFString*)destination;

/*!
 * @brief Renames an item.
 *
 * The destination path must be a full path, which means it must include the
 * name of the item.
 *
 * @param source The item to rename
 * @param destination The new name for the item
 */
+ (void)renameItemAtPath: (OFString*)source
		  toPath: (OFString*)destination;

Modified src/OFFile.m from [d5e09aa3e8] to [726f0b6ba9].

541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
#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([destination
		cStringWithEncoding: OF_STRING_ENCODING_NATIVE], &s) == 0) {
#else
	if (_wstat([destination UTF16String], &s) == 0) {
#endif
		errno = EEXIST;







<
<
<
<
<
<







541
542
543
544
545
546
547






548
549
550
551
552
553
554
#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;
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
	void *pool;

	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 (rename([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    [destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#else
	if (_wrename([source UTF16String], [destination UTF16String]))
#endif
		@throw [OFRenameItemFailedException







<
<
<
<
<
<







671
672
673
674
675
676
677






678
679
680
681
682
683
684
	void *pool;

	if (source == nil || destination == nil)
		@throw [OFInvalidArgumentException exception];

	pool = objc_autoreleasePoolPush();







#ifndef _WIN32
	if (rename([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    [destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#else
	if (_wrename([source UTF16String], [destination UTF16String]))
#endif
		@throw [OFRenameItemFailedException