ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rich Wagner <rich.wag...@savaje.com>
Subject Re: test for directory existence
Date Wed, 15 Feb 2006 16:14:13 GMT
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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message