Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Jun 2000 02:10:39 +0930 (CST)
From:      Greg Lewis <glewis@trc.adelaide.edu.au>
To:        Greg Lewis <glewis@trc.adelaide.edu.au>
Cc:        Rob Furphy <rcf@ox.com>, freebsd-java@FreeBSD.ORG
Subject:   Re: can't remove directories?
Message-ID:  <200006021640.CAA31260@ares.trc.adelaide.edu.au>
In-Reply-To: <200006021630.CAA22648@ares.trc.adelaide.edu.au> from Greg Lewis at "Jun 3, 2000 02:00:04 am"

next in thread | previous in thread | raw e-mail | index | archive | help
Greg Lewis wrote:
[a buggered up patch.  Note to self: No more late night hacking!]

Right, that will teach me to add a comment after I compiled something.  The
last patch was missing the closing */ on the second comment.  So here is
what the patch should look like, and this one will compile.

Index: src/freebsd/native/java/io/UnixFileSystem_md.c
===================================================================
RCS file: /data/java/JDK2/javasrc/src/freebsd/native/java/io/UnixFileSystem_md.c,v
retrieving revision 1.3
diff -u -r1.3 UnixFileSystem_md.c
--- src/freebsd/native/java/io/UnixFileSystem_md.c	2000/04/13 14:05:57	1.3
+++ src/freebsd/native/java/io/UnixFileSystem_md.c	2000/06/02 16:37:00
@@ -237,7 +237,17 @@
     jboolean rv = JNI_FALSE;
 
     WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
+#ifdef __FreeBSD__
+        /*
+	 * Under FreeBSD remove(3) is simply an alias for unlink(2).  This
+	 * is not the case on Linux and Solaris where remove() calls unlink()
+	 * for files and rmdir() for directories.  Duplicate this functionality
+	 * here by trying rmdir should unlink fail.
+	 */
+	if (unlink(path) == 0 || rmdir(path) == 0) {
+#else
 	if (remove(path) == 0) {
+#endif
 	    rv = JNI_TRUE;
 	}
     } END_PLATFORM_STRING(env, path);
@@ -250,7 +260,18 @@
 					 jobject file)
 {
     WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
+#ifdef __FreeBSD__
+        /*
+	 * Under FreeBSD remove(3) is simply an alias for unlink(2).  This
+	 * is not the case on Linux and Solaris where remove() calls unlink()
+	 * for files and rmdir() for directories.  Duplicate this functionality
+	 * here by trying rmdir should unlink fail.
+         */
+	deleteOnExit(env, path, unlink);
+	deleteOnExit(env, path, rmdir);
+#else
 	deleteOnExit(env, path, remove);
+#endif
     } END_PLATFORM_STRING(env, path);
     return JNI_TRUE;
 }
-- 
Greg Lewis 				glewis@trc.adelaide.edu.au
Computing Officer			+61 8 8303 5083
Teletraffic Research Centre


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200006021640.CAA31260>