Date: Fri, 2 Jun 2000 10:37:12 +0930 (CST) From: Greg Lewis <glewis@trc.adelaide.edu.au> To: Ronaldo Carpio <rncarpio@yahoo.com> Cc: freebsd-java@FreeBSD.ORG Subject: Re: can't remove directories? Message-ID: <200006020107.KAA30783@ares.trc.adelaide.edu.au> In-Reply-To: <20000601201042.21618.qmail@web701.mail.yahoo.com> from Ronaldo Carpio at "Jun 1, 2000 01:10:42 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
Ronaldo Carpio wrote:
> Running 4.0-stable, jdk1.2.2 and patchset 8, I can't remove a directory
> with File.delete(). The source seems to call remove(), which should work
> on both files and dirs, but man remove says that it's just an alias for
> unlink. Am I smoking crack?
I can't comment on your crack smoking or lack thereof, but this definitely
looks like a bug ;). Thanks for the report!
From a quick look at the man page for unlink(2) I'll note:
ERRORS
The unlink() succeeds unless:
...
[EPERM] The named file is a directory.
rmdir(2) needs to be used if we're trying to remove a directory.
Assuming thats the case, a (completely untested) patch might be:
--- src/freebsd/native/java/io/UnixFileSystem_md.c~ Tue Apr 11 10:00:56 2000
+++ src/freebsd/native/java/io/UnixFileSystem_md.c Fri Jun 2 10:34:46 2000
@@ -237,7 +237,11 @@
jboolean rv = JNI_FALSE;
WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
+#ifdef __FreeBSD__
+ if (remove(path) == 0 || rmdir(path) == 0) {
+#else
if (remove(path) == 0) {
+#endif
rv = JNI_TRUE;
}
} END_PLATFORM_STRING(env, path);
--
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?200006020107.KAA30783>
