ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "STONE,ROBERT (Non-HP-SanDiego,ex1)" <bob_sto...@non.hp.com>
Subject RE: How to get just the file/dir name from a FileSet item?
Date Wed, 04 Sep 2002 23:02:32 GMT

> I'm trying to provide a prompt list for the user as follows:
> 1. Use foreach to iterate through the list of files/dirs
> 2. For each file - output current index and the base file name
> 3. Capture number input from the user and save the corresponding property
> 4. Do something based on the property obtained
> 
> For example, if we have a directory with 3 files in it (foo, goo, boo),
> user will see the following
> 
> Please select from the list:
> 1) foo
> 2) goo
> 3) boo
> 
> User inputs the number, however the corresponding filename is used
> instead.
> 
> 2 questions:
> 1. How to increase the counter?
> 2. How to find the right filename?
> 
> -bob stone
> 
> > dunno, it seems to work :)  I do this:
> >
> >  <foreach target="-antntservice" param="service.dir">
> >    <fileset dir="${src}/windows/service/services" includes="*"/>
> >  </foreach>
> >
> >Since the only things in the .../service/services directory are other
> >directories, I assume it's matching those with the "*".  It is working
> that
> >way anyway.
> >
> >In my -antntservice target I then do:
> >
> >  <basename property="service.name" file="${service.dir}"/>
> >  <ant antfile="build_service.xml" target="${target}">
> >    <property name="service" value="${service.name}" />
> >  </ant>
> >
> >-----Original Message-----
> >From: Diane Holt [mailto:holtdl@yahoo.com]
> >Sent: Tuesday, August 13, 2002 11:24 PM
> >To: Ant Users List
> >Subject: RE: How to get just the file/dir name from a FileSet item?
> 
> 
> >--- Chris Bailey <chris@codeintensity.com> wrote:
> >> Ah, perfect, <basename> was all I needed, not sure why I'd missed that
> >> scanning through the tasks, but thanks!  I knew this could be done
> >> easily.
> >>
> >> Note, I can't use a DirSet because ForEach doesn't support it,
> otherwise
> >> I would be.  Probably something that should be fixed...
> 
> >Yeah, but <fileset> won't get you a set of directories -- it'll get you a
> >set of files. And <basename> will end up giving you the name of each file
> >in the fileset, not the last directory element (since you're not feeding
> >it a directory name, but rather, a filename). So I don't see how that's
> >going to do it for you. Seems to me you'd need to go through several
> >additional steps to get from a fileset to a list of base dir names to
> loop
> >through. (Then again, I'm sleep-deprived so maybe I'm just missing it,
> and
> >you're actually fine with using it.)
> 
> >Diane
> 
> >=====
> >(holtdl@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