ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Reilly" <peter.kitt.rei...@gmail.com>
Subject Re: Getting relative pathes in a for loop
Date Wed, 22 Mar 2006 09:17:52 GMT
I use propertyregex with the help of a macro:
  <!-- *********************************************
       Macro to set a property to the first
       group of a regexp applied on an input string.
       ********************************************** -->
  <macrodef name="regset1">
    <attribute name="regexp"/>
    <attribute name="input"/>
    <attribute name="property"/>
    <sequential>
      <ac:propertyregex override="yes"
                        property="@{property}"  input="@{input}"
                        regexp="@{regexp}" replace="\1"/>
    </sequential>
  </macrodef>

          <regset1 property="program" input="@{file}"
                  regexp=".*/([^\.]*)\.cpp"/>

In this case I am using the /dir/dir/dir/x.cpp name and
extracting the x as the program name.


On 3/21/06, Ivan Rambius Ivanov <rambiusparkisanius@yahoo.com> wrote:
>
> Hello,
>
> In your case you can use <basename> to get the name of
> the file. For more sophisticated operations on paths
> you may find useful <pathconvert> with nested
> <mapper>.
>
> Regards
> Ivan
>
> --- ar81 <armaillist@free.fr> wrote:
>
> > Hi all,
> >
> > When I write the following loop, I get absolute file
> > pathes.
> >
> >       <for param="file">
> >           <path>
> >              <fileset dir="${work.dir}"
> > includes="**/*.xml"/>
> >           </path>
> >           <sequential>
> >              <echo message="File : @{file}" />
> >           </sequential>
> >        </for>
> >
> > C:\Temp\dir1\file1.xml
> > C:\Temp\dir1\file2.xml
> > C:\Temp\dir1\file3.xml
> >
> > where work.dir=C:\Temp\dir1
> >
> > I'd like to get :
> > file1.xml
> > file2.xml
> > file3.xml
> >
> > Does anybody know how to transform absolute pathes
> > to relative pathes ?
> >
> > Thanks
> >
> > A. ROY
> >
> >
> >
> ---------------------------------------------------------------------
> > 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message