ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Gainty" <mgai...@hotmail.com>
Subject Re: test for directory existence
Date Wed, 15 Feb 2006 17:35:36 GMT
<available tag works>
Thanks Rich!
M-

----- Original Message ----- 
From: "Rich Wagner" <rich.wagner@savaje.com>
To: "Ant Users List" <user@ant.apache.org>; <mgainty@hotmail.com>
Sent: Wednesday, February 15, 2006 11:14 AM
Subject: Re: test for directory existence


> These prompt for a (relative or absolute) path, and conditionally set a 
> property based on directory existence, and echo a message that reports 
> whether there's a directory at the given path:
> 
>    <target name="ask_for_path_and_echo_existence"
>            depends="exists,does_not_exist"/>
> 
>    <target name="ask_for_dir">
>        <input message="Enter path:" addproperty="PATH"/>
>        <property name="ABSOLUTE_PATH" location="${PATH}"/>
>        <available file="${ABSOLUTE_PATH}" type="dir"
>                   property="DIR.present"/>
>    </target>
> 
>    <target name="exists" depends="ask_for_dir" if="DIR.present">
>        <echo message="Directory exists:  ${ABSOLUTE_PATH}"/>
>    </target>
> 
>    <target name="does_not_exist" depends="ask_for_dir" 
> unless="DIR.present">
>        <echo message="Directory does NOT exist, or not a directory:  
> ${ABSOLUTE_PATH}"/>
>    </target>
> 
> 
> Hope this helps,
> Rich Wagner
> 
> 
> 
> Martin Gainty wrote:
> 
>> Good Morning All-
>>
>> How do you test for the existence of a folder before del or mkdir 
>> operation
>> Has something to with <property ???
>>
>> Thanks!
>>
>> Martin Gainty
>>
>> (mobile) 603-438-5053
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>>
> 
>
Mime
View raw message