Date: Fri, 02 Jun 2000 11:21:14 -0400 From: Rob Furphy <rcf@ox.com> Cc: freebsd-java@FreeBSD.ORG Subject: Re: can't remove directories? Message-ID: <3937D0EA.D9D1E8BE@ox.com> References: <200006020107.KAA30783@ares.trc.adelaide.edu.au>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3937D0EA.D9D1E8BE>