ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Georg-Johann Lay <...@gjlay.de>
Subject Re: [ant] Determining relative paths resp. substring?
Date Fri, 16 Jan 2009 23:31:30 GMT
Georg-Johann Lay schrieb:
> 
> Ant proper really is not capable to perform things that look in C like
> 
>  >> char * prefix;
>  >> char * path;
>  >> char * suffix = path + strlen (prefix);
> 
> or like
> 
>  >> String prefix;
>  >> String path;
>  >> String suffix = path.substring (prefix.length());
> 
> in Java?

Hi, I found this solution:

     <!-- remove prefix from path -->
     <tempfile property="prefix.file" />
     <echo message="${path}" file="${prefix.file}" />
     <length property="prefix.length" string="${prefix}" />
     <replaceregexp file="${prefix.file}" 
match="^.{${prefix.length}}(.*)" replace="path.suffix=\1" />
     <property file="${prefix.file}" />
     <delete file="${prefix.file}" deleteonexit="true" />

     <echo message="path.suffix=${path.suffix} via ${prefix.file}" />

What I don't like are the accesses to the file system.
Can they be avoided?

You ant experts certanly know smarter ways to do this :-)

Regards, Georg-Johann


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


Mime
View raw message