ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivan Ivanov <rambiusparkisan...@yahoo.com>
Subject Re: Test for empty folder?
Date Wed, 27 Jul 2005 17:41:11 GMT
Hello,

the following script sets a property depending whether
a given folder is empty or not:

<project>
    <mkdir dir="empty"/>
    <fileset dir="empty" id="empty.fs"/>
    <pathconvert setonempty="false"
        property="emptyprop"
        refid="empty.fs"
        dirsep="${file.separator}"
        pathsep="${path.separator}">
    </pathconvert>
    <echo>$${emptyprop} is ${emptyprop}</echo>

    <mkdir dir="notempty"/>
    <touch file="notempty/file"/>
    <fileset dir="notempty" id="not.empty.fs"/>
    <pathconvert setonempty="false"
        property="notemptyprop"
        refid="not.empty.fs"
        dirsep="${file.separator}"
        pathsep="${path.separator}">
    </pathconvert>
    <echo>$${notemptyprop} is ${notemptyprop}</echo>
</project>

You might want to isolate the above code in a
<macrodef> for easier reusing.

Note that this is pure ant solution. You can easily do
the check as well using <scriptdef> with javascript
for example.

HTH Ivan

--- Michael Owen <michaelowenuk@hotmail.com> wrote:

> Hi,
> 
> How do can test if a folder is empty?
> 
> Mike
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message