You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Jay Glanville <di...@nortelnetworks.com> on 2000/12/07 23:50:16 UTC
Why can't just simply delete the directory?
I'm currently using a nightly build for Oct 11 2000.
I have a clean task that does something like the following:
<target name="clean" >
<delete dir="${build.loc}" />
</target>
The task performs beautifully, but not efficiently. Before it deletes the
directory, it deletes all the files within it. However, when my
${build.loc} contains over 4000 files, this deleting of files can take a
while. (true, only a little over 60 seconds) Why can't it simply delete the
directory itself?
----------------------------------------------------------------------------
-----
Jay Dickon Glanville
P068 - SiteManager Development, Nortel Networks
613-765-1144 (ESN 395-1144)
MS: 045/55/A05
E-Mail: dickon@nortelnetworks.com
Re: Why can't just simply delete the directory?
Posted by Stefan Bodewig <bo...@apache.org>.
Jay Glanville <di...@nortelnetworks.com> wrote:
> The task performs beautifully, but not efficiently. Before it
> deletes the directory, it deletes all the files within it.
File.delete will not delete a directory unless it's empty, sorry.
Stefan
Re: Why can't just simply delete the directory?
Posted by James Duncan Davidson <du...@x180.net>.
On 12/7/00 2:50 PM, "Jay Glanville" <di...@nortelnetworks.com> wrote:
> The task performs beautifully, but not efficiently. Before it deletes the
> directory, it deletes all the files within it. However, when my
> ${build.loc} contains over 4000 files, this deleting of files can take a
> while. (true, only a little over 60 seconds) Why can't it simply delete the
> directory itself?
When I was first writing ant -- I tried to just file.delete(); and was
disappointed that it didn't work. However, the Javadoc for the method
specifies:
"Deletes the file or directory denoted by this abstract pathname. If this
pathname denotes a directory, then the directory must be empty in order to
be deleted."
There's no equivalent to 'rm -rf' in the java.io.File class -- so chasing
the tree down and nuking all files, then all directories, back to the parent
is the only way to do it.
.duncan
--
James Duncan Davidson duncan@x180.net
!try; do()