ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Weintraub" <qazw...@gmail.com>
Subject Re: Check if a directory is empty
Date Tue, 09 Oct 2007 18:03:40 GMT
Hmmm...

You could create a PATH ID, then convert that over to a property, then
check that the property is not empty. The following build.xml has been
tested and checks for the presents of files in that directory.
However, it will report a directory as empty if it contains just empty
directories:

<project name="test" default="test" basedir=".">

    <path id="test.me">
        <fileset dir="${basedir}/test.dir"/>
    </path>

    <property name="test.me.property" refid="test.me"/>

    <condition property="empty.dir.flag">
        <equals arg1="" arg2="${test.me.property}"/>
    </condition>

    <target name="test1"
        if="empty.dir.flag">
        <echo>Directory "test.dir" is empty</echo>
    </target>

    <target name="test"
        depends="test1"
        unless="empty.dir.flag">
        <echo>Directory "test.dir" is not empty</echo>
    </target>
</project>

I was seeing if there was someway to do this via a filterchange, but
couldn't see anyway.

--
David Weintraub
qazwart@gmail.com

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


Mime
View raw message