From owner-freebsd-java Fri Jun 2 8:21:27 2000 Delivered-To: freebsd-java@freebsd.org Received: from firewall.ox.com (firewall.ox.com [129.77.1.1]) by hub.freebsd.org (Postfix) with ESMTP id AE36037BC75 for ; Fri, 2 Jun 2000 08:21:16 -0700 (PDT) (envelope-from rcf@ox.com) Received: from firewall.ox.com (root@localhost) by firewall.ox.com with ESMTP id LAA02996 for ; Fri, 2 Jun 2000 11:21:15 -0400 (EDT) Received: from pur-wk-rfurphy.ny.ox.com (pur-wk-rfurphy.ny.ox.com [129.77.2.133]) by firewall.ox.com with ESMTP id LAA02992 for ; Fri, 2 Jun 2000 11:21:15 -0400 (EDT) Received: from ox.com (localhost.ny.ox.com [127.0.0.1]) by pur-wk-rfurphy.ny.ox.com (8.9.3/8.9.3) with ESMTP id LAA47970 for ; Fri, 2 Jun 2000 11:21:14 -0400 (EDT) (envelope-from rcf@ox.com) Message-ID: <3937D0EA.D9D1E8BE@ox.com> Date: Fri, 02 Jun 2000 11:21:14 -0400 From: Rob Furphy X-Mailer: Mozilla 4.73 [en] (X11; U; FreeBSD 3.4-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 Cc: freebsd-java@FreeBSD.ORG Subject: Re: can't remove directories? References: <200006020107.KAA30783@ares.trc.adelaide.edu.au> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Greg, Your patch works for File.delete(). Here's another problem File.deleteOnExit() has the same problem...even with the patch applied. I've spent about 2 hours looking and I can't find a fix. Got to get to work now so I have to stop. The problem is that deleteOnExit() deletes files specified but not directories specified. Rob F. Greg Lewis wrote: > 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 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message