You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Emmanuel Blot <eb...@jijia12.grenoble.hp.com> on 2000/06/30 11:56:11 UTC

mkdir and rmdir / Windows

Hello,

I think there is something to improve with ANT when it runs on Windows ;^( :
Whenever it tries to remove a directory that is 'busy' by any other application, the removal failed (that is ok), but ANT does not
detect this failure.
Then, whenever it tries to (re)create the same directory, it failed (that is ok) because the directory already exists (since it
has not been deleted). At this point, ANT bails out.

It think the best (as Windows is really a stupid thing) is to detect, whenever a directory creation failed, if this directory does
already exist, and to skip the failure in this case.
Or, to bail out whenever a directory removal fails.

Emmanuel.



Re: mkdir and rmdir / Windows

Posted by Emmanuel Blot <eb...@jijia12.grenoble.hp.com>.
> Are you sure? I bet you are.

I often make mistakes 8')

Here is the log:

Executing Target: clean.out.dir
Deleting: F:\tmp\edelivery  # not actually done because one explorer windows was open onto this very directory.
Executing Target: out.dir
Created dir: F:\tmp\edelivery
BUILD FATAL ERROR: Directory f:\tmp/edelivery/jar creation was not succesful for an unknown reason

Here is a part of the build.xml:

(build.dir is f:\tmp\edelivery)
<target name="out.dir" depends="init"> <mkdir dir="${build.dir}"/> <mkdir dir="${build.dir}/jar"/> </target>
 
> Mkdir checks whether the directory already exists and only tries to
> create the dir, if it isn't there. I have no Windows box around to
> check but it seems that for some reasons Ant thinks the dir is not
> there - so ignore the error is no option as Ant doesn't know the dir
> does exist.

That is not so important, anyway. I just have to change the explorer current directory.
The problem is a Windows poroblem, not ANT one.

Thanks,
Emmanuel.


Re: mkdir and rmdir / Windows

Posted by Steve Loughran <st...@iseran.com>.
----- Original Message -----
From: "Conor MacNeill" <co...@m64.com>
To: <an...@jakarta.apache.org>
Sent: Friday, June 30, 2000 05:02
Subject: RE: mkdir and rmdir / Windows


> > It is really an operating system level issue.
> If, for example, you have a directory in an explorer window and you do
> 'build clean' which deletes that directory, it seems that the directory
will
> continue to exist albeit in some transient state. The directory will
appear
> in directory listings but any attempt to use it will get an "access
denied".
> Try it from the command line to see that this is not peculiar to ant. Once
> you "let go" in the explorer window, the directory disappears from the
> filesystem.
>
> Whilst the directory is in this transient state, it appears that
> File.exists() will return false but that any attempt to create the
directory
> quite naturally fails.
>
> Not much to be done.

You could find all running copies of explorer.exe and kill them, but it
would probably be considered antisocial.

I think, putting on my wintel hacker hat, that you could locate explorer and
talk to it enough for it to let go gracefully (This happens when network and
other drives are mounted after all). It is probably something trivial like
broadcasting a device change message, which could be tapped into 5 lines of
win32 app. But it would be a test nightmare, -I would need to test the whole
set of (win95, 95.2, 98, 98.1, 98.me, Nt4, win2k) against the spread of
explorer versions out there (classic, IE4, IE5).

So raising an exception is the only rational option.

-steve



RE: mkdir and rmdir / Windows

Posted by Tom Dimock <ta...@cornell.edu>.
At 10:59 PM 06/30/2000 +1000, Conor wrote:
>2. The indenting in the delete task is now 2 characters instead of 4. This
>appears to have occurred when the Matching Task patch from Tim Dimock was
>committed. Worth fixing? I think so.

Oops!  Sorry about that.  Our shop standard is 2 characters, and almost any
code I touch gets run through Jindent to normalize the formatting.  I
actually have a Jindent task for Ant that gets called as part of the build
process.   I'll not do that (or set up a Jindent profile for the Ant
standard formatting) in the future.
----------------------------------------------------------------------------
       Tom Dimock  ----  Cornell University  ----  tad1@cornell.edu
"There go my people.  I must follow them, for I am their leader."  M. Gandhi

Re: mkdir and rmdir / Windows

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "CM" == Conor MacNeill <co...@m64.com> writes:

 CM> 1. If deltree points to a file, it deletes the file.

 CM> I think we should change that to throw an exception.

Yes, although I think deltree is going to be deprecated anyway.

 CM> 3. logging in place of exceptions. I notice that <delete> logs
 CM> errors and doesn't throw exceptions. I would prefer to have most
 CM> of these as exceptions

+1

Stefan

RE: mkdir and rmdir / Windows

Posted by Conor MacNeill <co...@m64.com>.
> -----Original Message-----
> We should change deltree and delete to throw an exception if they fail
> to delete anything then, so you would recognize you open Explorer
> window in the cleanup phase - or start searching for the coworker who
> left it open, argh.

OK, I've committed the code for that. I came across a few interesting
issues, however.

1. If deltree points to a file, it deletes the file. Perhaps this explains
Stefano's comment on the initial checkin of Delete "new task: delete single
file (strangely it was missing)"

I think we should change that to throw an exception. (This is commented out
at present).

2. The indenting in the delete task is now 2 characters instead of 4. This
appears to have occurred when the Matching Task patch from Tim Dimock was
committed. Worth fixing? I think so.

3. logging in place of exceptions. I notice that <delete> logs errors and
doesn't throw exceptions. For example if you pass a directory to the file
attribute, it just logs a message (at INFO logging level). I would prefer to
have most of these as exceptions. I prefer to blowup sooner. Of course, this
rule is not hard and fast as we discussed over the operation of <touch>
under 1.1 situation.

Comments?


Re: mkdir and rmdir / Windows

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "CM" == Conor MacNeill <co...@m64.com> writes:

 CM> Whilst the directory is in this transient state, it appears that
 CM> File.exists() will return false but that any attempt to create
 CM> the directory quite naturally fails.

I see, I vaguely remember that I've seen such behavior before. Thanks.

 CM> Not much to be done.

Agreed.

We should change deltree and delete to throw an exception if they fail
to delete anything then, so you would recognize you open Explorer
window in the cleanup phase - or start searching for the coworker who
left it open, argh.

Stefan

RE: mkdir and rmdir / Windows

Posted by Conor MacNeill <co...@m64.com>.
> -----Original Message-----
> From: Stefan Bodewig [mailto:bodewig@bost.de]
> Sent: Friday, 30 June 2000 21:23
> To: ant-dev@jakarta.apache.org
> Subject: Re: mkdir and rmdir / Windows
>
>
> >>>>> "EB" == Emmanuel Blot <eb...@jijia12.grenoble.hp.com> writes:
>
>  EB> Then, whenever it tries to (re)create the same directory, it
>  EB> failed (that is ok) because the directory already exists (since
>  EB> it has not been deleted). At this point, ANT bails out.
>
> Are you sure? I bet you are.
>

Well I am sure that ant does indeed bail out. I do not think it can be
overcome within ant however. It is really an operating system level issue.
If, for example, you have a directory in an explorer window and you do
'build clean' which deletes that directory, it seems that the directory will
continue to exist albeit in some transient state. The directory will appear
in directory listings but any attempt to use it will get an "access denied".
Try it from the command line to see that this is not peculiar to ant. Once
you "let go" in the explorer window, the directory disappears from the
filesystem.

Whilst the directory is in this transient state, it appears that
File.exists() will return false but that any attempt to create the directory
quite naturally fails.

Not much to be done.

Conor


Re: mkdir and rmdir / Windows

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "EB" == Emmanuel Blot <eb...@jijia12.grenoble.hp.com> writes:

 EB> Then, whenever it tries to (re)create the same directory, it
 EB> failed (that is ok) because the directory already exists (since
 EB> it has not been deleted). At this point, ANT bails out.

Are you sure? I bet you are.

Mkdir checks whether the directory already exists and only tries to
create the dir, if it isn't there. I have no Windows box around to
check but it seems that for some reasons Ant thinks the dir is not
there - so ignore the error is no option as Ant doesn't know the dir
does exist.

Stefan