ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject Re: Counting files in a dir
Date Tue, 05 Apr 2005 16:05:45 GMT
--- Fermin Da Costa Gomez <f.dacosta.g@gmail.com>
wrote:
> Hi,
> 
> What would be the best way to do the following:
> 1. Going into a directory (this is ok)
> 2. Counting the number of files of type x (getting
> files is ok, *counting* is an 
> issue)

With Ant 1.6.3 (now in beta) you could do this:

<pathconvert property="foo" pathsep="">
  <path>
    <fileset dir="foo" includes="*.foo" />
  </path>
  <mergemapper to="-" />
</pathconvert>

<length string="${foo}" property="foo.length" />

(look for a cooler way to do this in Ant 1.7!)

> 3. Depending on the count do something (break out of
> the target)
> 
> Items 2. and 3. are bugging me somewhat (esp the
> counting bit in 2).
> Does anybody have a suggestion as to how i can
> accomplish this?

3. depends on what the comparison is... rather than
break out of a target, however, you are probably
better off to decompose your build so that the part
you want to skip by breaking out is in its own target,
which depends on a target that does this count-check. 
Most likely you will test its results with another
condition to set a property (or not), and whether this
property is set will determine whether the final
target is run.  Under what circumstances do you NOT
want to continue, after having counted the files? 
What actions are you trying to avoid?

-Matt
> 
> tia,
> 
> Fermin DCG
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 


		
__________________________________ 
Yahoo! Messenger 
Show us what our next emoticon should look like. Join the fun. 
http://www.advision.webevents.yahoo.com/emoticontest

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


Mime
View raw message