From owner-freebsd-java Thu Jun 1 18: 7:36 2000 Delivered-To: freebsd-java@freebsd.org Received: from ares.trc.adelaide.edu.au (ares.trc.adelaide.edu.au [129.127.246.5]) by hub.freebsd.org (Postfix) with ESMTP id 6B97637B9A7 for ; Thu, 1 Jun 2000 18:07:31 -0700 (PDT) (envelope-from glewis@ares.trc.adelaide.edu.au) Received: (from glewis@localhost) by ares.trc.adelaide.edu.au (8.9.3/8.9.3) id KAA30783; Fri, 2 Jun 2000 10:37:12 +0930 (CST) (envelope-from glewis) From: Greg Lewis Message-Id: <200006020107.KAA30783@ares.trc.adelaide.edu.au> Subject: Re: can't remove directories? In-Reply-To: <20000601201042.21618.qmail@web701.mail.yahoo.com> from Ronaldo Carpio at "Jun 1, 2000 01:10:42 pm" To: Ronaldo Carpio Date: Fri, 2 Jun 2000 10:37:12 +0930 (CST) Cc: freebsd-java@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL70 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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