FAQ

[Ant-user] fileset: exlude a dir not to be touched by ant?

Schumacher
Nov 14, 2002 at 11:21 am
I cannot exclude a directory from being touched.
The solution has to be simple, any advice?

I tried a simple task:
deleting all files with *.bak at the end.
No problem so far.
But in XP there is a directory called
C:\System Volume Information

I cannot exlude it from being touched.

I tried
<exclude name="C:\System Volume Information\*"/>
as well as
<exclude name="C:\System*"/>

but all leads to an ant error:

BUILD FAILED
file:C://build.xml:12: IO error scanning directory C:\System Volume
Information
at
org.apache.tools.ant.DirectoryScanner.scandir(DirectoryScanner.java:6
41)
at
org.apache.tools.ant.DirectoryScanner.scandir(DirectoryScanner.java:7
02)
at
org.apache.tools.ant.DirectoryScanner.scan(DirectoryScanner.java:571)

at
org.apache.tools.ant.types.AbstractFileSet.getDirectoryScanner(Abstra
ctFileSet.java:379)
at org.apache.tools.ant.taskdefs.Delete.execute(Delete.java:334)
at org.apache.tools.ant.Task.perform(Task.java:319)
at org.apache.tools.ant.Target.execute(Target.java:309)
at org.apache.tools.ant.Target.performTasks(Target.java:336)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
at org.apache.tools.ant.Project.executeTargets(Project.java:1250)
at org.apache.tools.ant.Main.runBuild(Main.java:610)
at org.apache.tools.ant.Main.start(Main.java:196)
at org.apache.tools.ant.Main.main(Main.java:235)


--
To unsubscribe, e-mail:
For additional commands, e-mail:
reply

Search Discussions

11 responses

  • Stefan Bodewig at Nov 14, 2002 at 11:25 am

    On Thu, 14 Nov 2002, schumacher wrote:

    I cannot exclude a directory from being touched.
    The solution has to be simple, any advice?
    As you are not givin the full context, the answer is difficult.

    Does the hint that name="foo" expects foo to be a path relative to the
    dir attribute of the fileset and *not* an absolute path help?

    Stefan

    --
    To unsubscribe, e-mail:
    For additional commands, e-mail:
  • Rolf Schumacher at Nov 14, 2002 at 12:08 pm
    Sorry not to include the ant source - and: no, dir=C:\ and exclude
    name="System*"
    the error message remains

    <project name="clean hard disk" default="clean">
    <target name="clean">
    <delete>
    <fileset dir="C:\" defaultexcludes="no">
    <include name="**/*.class"/>
    <include name="**/*.*~"/>
    <include name="**/*.bak"/>
    <exclude name="System*"/>
    </fileset>
    </delete>
    </target>
    </project>

    By the way: I'm never sure as I have to escape the backslash or not,
    but in this case I tried both.

    Rolf

    Stefan Bodewig wrote:
    On Thu, 14 Nov 2002, schumacher wrote:


    I cannot exclude a directory from being touched.
    The solution has to be simple, any advice?
    As you are not givin the full context, the answer is difficult.

    Does the hint that name="foo" expects foo to be a path relative to the
    dir attribute of the fileset and *not* an absolute path help?

    Stefan

    --
    To unsubscribe, e-mail: For additional commands, e-mail:



    --
    To unsubscribe, e-mail:
    For additional commands, e-mail:
  • Stefan Bodewig at Nov 14, 2002 at 12:20 pm
    On Thu, 14 Nov 2002, Rolf Schumacher <Rolf.Schumacher@hamburg.de>
    <exclude name="System*"/>
    excludes the files and directories in C:\ which start with System, but
    not the files below that. You probably want

    <exclude name="System*/**"/>
    By the way: I'm never sure as I have to escape the backslash or not,
    No.

    You may also need to look at the casesensitive attribute of <fileset>
    when running on Windows.

    Stefan

    --
    To unsubscribe, e-mail:
    For additional commands, e-mail:
  • Elankath, Tarun (Cognizant) at Nov 14, 2002 at 12:32 pm
    do a

    <exclude name="**/System*/**" />
    for excluding all directories having "System" in their paths.

    -----Original Message-----
    From: Rolf Schumacher
    Sent: Thursday, November 14, 2002 5:38 PM
    To: Ant Users List
    Subject: Re: fileset: exlude a dir not to be touched by ant?


    Sorry not to include the ant source - and: no, dir=C:\ and exclude
    name="System*"
    the error message remains

    <project name="clean hard disk" default="clean">
    <target name="clean">
    <delete>
    <fileset dir="C:\" defaultexcludes="no">
    <include name="**/*.class"/>
    <include name="**/*.*~"/>
    <include name="**/*.bak"/>
    <exclude name="System*"/>
    </fileset>
    </delete>
    </target>
    </project>

    By the way: I'm never sure as I have to escape the backslash or not,
    but in this case I tried both.

    Rolf

    Stefan Bodewig wrote:
    On Thu, 14 Nov 2002, schumacher wrote:


    I cannot exclude a directory from being touched.
    The solution has to be simple, any advice?
    As you are not givin the full context, the answer is difficult.

    Does the hint that name="foo" expects foo to be a path relative to the
    dir attribute of the fileset and *not* an absolute path help?

    Stefan

    --
    To unsubscribe, e-mail: For additional commands, e-mail:



    --
    To unsubscribe, e-mail:
    For additional commands, e-mail:
  • Rolf Schumacher at Nov 14, 2002 at 2:43 pm
    Thank you, Tarun, but this trial fails as well.
    It looks to me as if - for some reason -
    Ant tries to open a dircetory
    even if it should not do anything with it.

    Elankath, Tarun (Cognizant) wrote:
    do a

    <exclude name="**/System*/**" />
    for excluding all directories having "System" in their paths.



    --
    To unsubscribe, e-mail:
    For additional commands, e-mail:
  • Rolf Schumacher at Nov 14, 2002 at 2:34 pm
    Thanks for your answer, Stefan. Nevertheless ant resists to understand me.
    It should not touch the directory System Volume Information.
    I believe that this is a special entry in the directory
    that leads to an error message even if ant asks for read only.

    Stefan Bodewig wrote:
    On Thu, 14 Nov 2002, Rolf Schumacher <Rolf.Schumacher@hamburg.de>


    <exclude name="System*"/>
    excludes the files and directories in C:\ which start with System, but
    not the files below that. You probably want

    <exclude name="System*/**"/>


    By the way: I'm never sure as I have to escape the backslash or not,
    No.

    You may also need to look at the casesensitive attribute of <fileset>
    when running on Windows.

    Stefan

    --
    To unsubscribe, e-mail: For additional commands, e-mail:



    --
    To unsubscribe, e-mail:
    For additional commands, e-mail:
  • Stefan Bodewig at Nov 15, 2002 at 7:37 am

    On Thu, 14 Nov 2002, Rolf Schumacher wrote:

    It should not touch the directory System Volume Information. I
    believe that this is a special entry in the directory that leads to
    an error message even if ant asks for read only.
    I'm afraid this happens before Ant actually looks at the file names.

    If you do a File#list on C:\ from a simple test program, do you get
    similar errors? It looks as if listing it may be enough to get you
    into trouble (as Ant really shouldn't try to access it after that).

    Stefan

    --
    To unsubscribe, e-mail:
    For additional commands, e-mail:
  • Elankath, Tarun (Cognizant) at Nov 15, 2002 at 6:57 am
    Rolf,

    I just did a test by creating a "System Volume Information"
    directory here, putting some files inside it and running the delete task on
    it. It worked with no problems on windows.
    I suggest you try doing the same and figuring out whether only the
    special "System Volume Information" on C:\ gives the problem that you
    mention or it happens for any directory with the given name.

    In case the latter occurs (rather doubtful), just try upgrading your
    java and ant. I wouldn't know what to do incase the former occurs. I can't
    try your script here on C:\ for obvious reasons :-)
    I can only suggest trying both the full name "System Volume
    Information" or the DOS name System~1


    Hope that helps,
    Tarun

    -----Original Message-----
    From: Rolf Schumacher
    Sent: Thursday, November 14, 2002 8:13 PM
    To: Ant Users List
    Subject: Re: fileset: exlude a dir not to be touched by ant?


    Thank you, Tarun, but this trial fails as well.
    It looks to me as if - for some reason -
    Ant tries to open a dircetory
    even if it should not do anything with it.

    Elankath, Tarun (Cognizant) wrote:
    do a

    <exclude name="**/System*/**" />
    for excluding all directories having "System" in their paths.



    --
    To unsubscribe, e-mail:
    For additional commands, e-mail:
  • Rolf Schumacher at Nov 15, 2002 at 11:19 am
    Thanks, Stefan.
    Sorry I'm not so professional in Ant - do not know what you mean by
    "File#list".
    What I've done is a simle Test:

    import java.io.File;
    public class Test {
    public static void main(String[] args) {
    File[] fs = (new File("C:\\")).listFiles();
    for(int i=0; i<fs.length; i++) {
    System.out.println(fs[i].getAbsolutePath());
    }
    }
    }

    This lists all top level files correctly without errors.
    Including "System Volume Information".
    What I thought is that Ant shoulde to stop here, not going further.
    It should evalutate the resulting strings (here in fs)
    against the filter <exclude name="**\System*\**> (or equiv.)
    prior to touching "C:\\System Volume Information".
    And than refuse to touch it.

    However, if I change my little test and do a touch to that file as in

    import java.io.File;
    public class Test {
    public static void main(String[] args) {
    File f = new File("C:\\System Volume Information");
    if (f.isDirectory()) {
    System.out.println("is directory");
    File[] fs = f.listFiles();
    if ( fs == null ) {
    System.out.println("directory is empty");
    }
    }
    }
    }

    I got no errors only my message that this directory is empty.

    It looks to me as if I don't see the wood for the trees
    or Ant touches the File in a more complex way to generate its error.
    I'm looking forward to overcome my blindness or crack this damn thing.

    Rolf

    Stefan Bodewig wrote:
    On Thu, 14 Nov 2002, Rolf Schumacher wrote:


    It should not touch the directory System Volume Information. I
    believe that this is a special entry in the directory that leads to
    an error message even if ant asks for read only.
    I'm afraid this happens before Ant actually looks at the file names.

    If you do a File#list on C:\ from a simple test program, do you get
    similar errors? It looks as if listing it may be enough to get you
    into trouble (as Ant really shouldn't try to access it after that).

    Stefan

    --
    To unsubscribe, e-mail: For additional commands, e-mail:



    --
    To unsubscribe, e-mail:
    For additional commands, e-mail:
  • Stefan Bodewig at Nov 15, 2002 at 11:29 am

    On Fri, 15 Nov 2002, Rolf Schumacher wrote:

    do not know what you mean by "File#list".
    exactly what you've done 8-)
    What I thought is that Ant shoulde to stop here, not going further.
    This is what I'd expect as well (haven't looked at the actual code for
    months, though).
    if (f.isDirectory()) {
    Ant will at least do that as well.
    I got no errors only my message that this directory is empty.
    Strange.

    If you want to look for yourself, DirectoryScanner in
    org.apache.tools.ant is the class performing all the filesystem stuff
    here.

    I'll look into it myself but may need you and yourself as a guinea pig
    - but please don't hold your breath.

    Stefan

    --
    To unsubscribe, e-mail:
    For additional commands, e-mail:
  • Rolf Schumacher at Nov 21, 2002 at 10:38 am
    Thanks, Stefan.
    I have to admit that I'm not familiar as to build Ant from source.
    What I need is an estimate on how long it would take to get Ant 1.5.1 up
    and running
    from source.
    With a working knowledge in Java and Ant, and a high speed connection
    to the internet at weekends only
    this might be a too lengthy task.

    Rolf

    Stefan Bodewig wrote:
    On Fri, 15 Nov 2002, Rolf Schumacher wrote:


    do not know what you mean by "File#list".
    exactly what you've done 8-)


    What I thought is that Ant shoulde to stop here, not going further.
    This is what I'd expect as well (haven't looked at the actual code for
    months, though).


    if (f.isDirectory()) {
    Ant will at least do that as well.


    I got no errors only my message that this directory is empty.
    Strange.

    If you want to look for yourself, DirectoryScanner in
    org.apache.tools.ant is the class performing all the filesystem stuff
    here.

    I'll look into it myself but may need you and yourself as a guinea pig
    - but please don't hold your breath.

    Stefan

    --
    To unsubscribe, e-mail: For additional commands, e-mail:



    --
    To unsubscribe, e-mail:
    For additional commands, e-mail:

Related Discussions

Discussion Navigation
viewthread | post