You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Alan Pearlman Spencer <Al...@Mobileaware.com> on 2001/11/14 16:26:25 UTC

Is there a way to search a directory structure?

Hi All,
Can this type of thing work for searching a dir tree?
I cant get it to work?
I'm trying to search for a file anywhere in a dir tree and set a
property
if that is there.
Like the available task, but I can't see how to get it to search a
complete tree.

I've tried:
<available resource="my.file.txt" type="file" property="found">
  <classpath>
    <fileset dir="${search.root}">
      <include name="**"/>
      <exclude name="**/*.*"/>
    </fileset>
  </classpath>
</available>

And also with filesets, but I'm stuck. Any ideas?
Alan.

-----Original Message-----
From: Alan Pearlman Spencer 
Sent: 08 November 2001 18:10
To: Ant Users List
Subject: RE: Is there a way to copy only a directory structure?


Thanks,
I got it to work by using, but it copies files with no extension...

    <copy todir="${foobar}"
          includeEmptyDirs="yes">
      <fileset dir="${foo}"
               excludes="**/*.*">
      </fileset>
    </copy>
I tried:** **.* **/* but they don't copy anything...
Thanks,
Alan.


-----Original Message-----
From: Matt Lyon [mailto:matt@stargus.com]
Sent: 08 November 2001 17:29
To: Ant Users List
Subject: RE: Is there a way to copy only a directory structure?


Hi,

Just a guess (don't have time to test it for you right now), but try:

    <copy todir="${foobar}"
          includeEmptyDirs="yes">
      <fileset dir="${foo}"
               excludes="**.*">
      </fileset>
    </copy>

Cheers,

Matt
-----Original Message-----
From: Alan Pearlman Spencer
[mailto:Alan.PearlmanSpencer@Mobileaware.com]
Sent: Thursday, November 08, 2001 12:37 PM
To: Ant Users List
Subject: Is there a way to copy only a directory structure?


I am interested in copying a whole directory tree from A to B but
not the files, only the structure.
Any ideas?

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Is there a way to search a directory structure?

Posted by Diane Holt <ho...@yahoo.com>.
--- Alan Pearlman Spencer <Al...@Mobileaware.com> wrote:
> Can this type of thing work for searching a dir tree?
> I cant get it to work?
> I'm trying to search for a file anywhere in a dir tree and set a
> property if that is there.
> Like the available task, but I can't see how to get it to search a
> complete tree.
> 
> I've tried:
> <available resource="my.file.txt" type="file" property="found">

The "resource" attribute is used when you're looking for something in a
jar-file. The "type" attribute is only valid when you've specified a file,
via the "file" attribute, as what you're looking for (and should check for
that and print an error -- my bad, so I'll fix that :)

>   <classpath>
>     <fileset dir="${search.root}">
>       <include name="**"/>
>       <exclude name="**/*.*"/>
>     </fileset>
>   </classpath>

The nested <classpath> is used when you've specified you're looking for
either a class or a resource, not when you're looking for a file (or
directory).

The documentation says you can use a nested <filepath> element when you're
looking for a file (or directory), but I can't get that to work, so either
I'm not doing it right, or there's a bug in how it's doing it (I'm leaning
towards that :)

For example, I tried:
  <target name="findFile">
    <available property="found" file="A.java">
      <filepath>
        <fileset dir=".">
          <include name="**"/>
        </fileset>
      </filepath>
    </available>
    <echo message="found = ${found}"/>
  </target>

Running this target with -verbose shows it recursively searching through
all the subdirs, so that's good -- but it looks like it's made the
filename it's looking for the full-path name, based on the basedir, so
even though the file exists several subdirectories down from basedir, it's
not going to match.

Even more unfortunately, though, I tried just 'touch'ing an A.java in the
local directory, and it didn't find it there, either :(  Looks like some
debugging is in order.

Diane

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



__________________________________________________
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>