ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <hol...@yahoo.com>
Subject Re: reverse glob mapper pattern?
Date Sun, 22 Sep 2002 00:16:56 GMT
--- Jacob Kjome <hoju@visi.com> wrote:
> So, I need to find all files that have a corresponding 
> "sample.*" file and delete those.
> 
> If I just use the following, it deletes the sample.* file, not the *
> file which is the opposite of what I want...
> [snip]
>                  <present present="both" targetdir="${src.dir}">
>                      <mapper type="glob" from="sample.*" to="*" />
>                  </present>

That's because it's returning what <present> says it will return, which is
just those files that do have equivalents -- it doesn't return the
equivalents as well.

> So, my question is, how do I set up a pattern where the fileset will get
> a list of the "*" files rather than the sample.* files to delete?

Generate the fileset the way you currently are, only do it outside of the
<delete>, id it, then use <pathconvert> to get a comma-separated list to
pass to 'includes' for the <delete>:
  <target name="doDelete">
    <fileset dir="${src.dir}" id="fs">
      <present targetdir="${src.dir}">
        <mapper type="glob" from="sample.*" to="*" />
      </present>
    </fileset>
    <pathconvert pathsep="," property="fs.sample" refid="fs">
      <map from="${src.dir}${file.separator}" to=""/>
    </pathconvert>
    <pathconvert pathsep="," property="fs.copy" refid="fs">
      <map from="${src.dir}${file.separator}sample." to=""/>
    </pathconvert>
    <property name="delete.includes" value="${fs.sample},${fs.copy}"/>
    <delete>
      <fileset dir="${src.dir}" includes="${delete.includes}"/>
    </delete>
  </target>

Diane


=====
(holtdl@yahoo.com)



__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

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


Mime
View raw message