ObjFW  Check-in [3c2d173940]

Overview
Comment:+[OFFile removeItemAtPath:]: Remove recursively.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3c2d17394000134453d520be956375830e0196dbfea463851eb76fb64ee364a2
User & Date: js on 2013-12-09 23:35:21
Other Links: manifest | tags
Context
2013-12-10
01:47
Ignore OBJC_ZEROCOST_EXCEPTIONS on ARM. check-in: 65d8a7c8ed user: js tags: trunk
2013-12-09
23:35
+[OFFile removeItemAtPath:]: Remove recursively. check-in: 3c2d173940 user: js tags: trunk
23:24
+[OFFile copyFileAtPath:toPath:]: Win32 stuff. check-in: aefb143a8d user: js tags: trunk
Changes

Modified src/OFFile.h from [31d02bd727] to [78ef5184a3].

197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
 */
+ (void)renameItemAtPath: (OFString*)source
		  toPath: (OFString*)destination;

/*!
 * @brief Removes the item at the specified path.
 *
 * If the item at the specified path is a directory, it needs to be empty.
 *
 * @param path The path to the item which should be removed
 */
+ (void)removeItemAtPath: (OFString*)path;

#ifdef OF_HAVE_LINK
/*!







|







197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
 */
+ (void)renameItemAtPath: (OFString*)source
		  toPath: (OFString*)destination;

/*!
 * @brief Removes the item at the specified path.
 *
 * If the item at the specified path is a directory, it is removed recursively.
 *
 * @param path The path to the item which should be removed
 */
+ (void)removeItemAtPath: (OFString*)path;

#ifdef OF_HAVE_LINK
/*!

Modified src/OFFile.m from [952a84375d] to [4da01770ca].

701
702
703
704
705
706
707







708
709





































710
711
712
713
714
715
716


717
718
719
720
721
722
723
			    destinationPath: destination];

	objc_autoreleasePoolPop(pool);
}

+ (void)removeItemAtPath: (OFString*)path
{







	if (path == nil)
		@throw [OFInvalidArgumentException exception];






































#ifndef _WIN32
	if (remove([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#else
	if (_wremove([path UTF16String]))
#endif
		@throw [OFRemoveItemFailedException exceptionWithPath: path];


}

#ifdef OF_HAVE_LINK
+ (void)linkItemAtPath: (OFString*)source
		toPath: (OFString*)destination
{
	void *pool;







>
>
>
>
>
>
>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







>
>







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
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
			    destinationPath: destination];

	objc_autoreleasePoolPop(pool);
}

+ (void)removeItemAtPath: (OFString*)path
{
	void *pool;
#ifndef _WIN32
	struct stat s;
#else
	struct _stat s;
#endif

	if (path == nil)
		@throw [OFInvalidArgumentException exception];

	pool = objc_autoreleasePoolPush();

#ifndef _WIN32
	if (lstat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE], &s))
#else
	if (_wstat([path UTF16String], &s))
#endif
		@throw [OFRemoveItemFailedException exceptionWithPath: path];

	if (S_ISDIR(s.st_mode)) {
		OFArray *contents;
		OFEnumerator *enumerator;
		OFString *item;

		@try {
			contents = [OFFile contentsOfDirectoryAtPath: path];
		} @catch (id e) {
			@throw [OFRemoveItemFailedException
			    exceptionWithPath: path];
		}

		enumerator = [contents objectEnumerator];
		while ((item = [enumerator nextObject]) != nil) {
			void *pool2 = objc_autoreleasePoolPush();
			OFArray *components;
			OFString *itemPath;

			components = [OFArray arrayWithObjects:
			    path, item, nil];
			itemPath = [OFString pathWithComponents: components];

			[OFFile removeItemAtPath: itemPath];

			objc_autoreleasePoolPop(pool2);
		}
	}

#ifndef _WIN32
	if (remove([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#else
	if (_wremove([path UTF16String]))
#endif
		@throw [OFRemoveItemFailedException exceptionWithPath: path];

	objc_autoreleasePoolPop(pool);
}

#ifdef OF_HAVE_LINK
+ (void)linkItemAtPath: (OFString*)source
		toPath: (OFString*)destination
{
	void *pool;