commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 30992] New: - DirectoryFileFilter does not work, the AbstractFileFilter bug
Date Wed, 01 Sep 2004 14:44:54 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30992>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30992

DirectoryFileFilter does not work, the AbstractFileFilter bug

           Summary: DirectoryFileFilter does not work, the
                    AbstractFileFilter bug
           Product: Commons
           Version: 1.0 Final
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: IO
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: nperunicic@yahoo.com


Env: Java 1.4.2, commons-io-1.0.jar, Win XP

The AbstractFileFilter's FilenameFilter's accept(File, String) method 
implementation constructs the fileName/File (it passes to accept(File)) 
wrongly - please see below. This causes the DirectoryFileFilter (in example, I 
did not have time to check out the other AbstractFileFilter implementations) 
failure since it's FileFilter implementation receives the incorrect 
filename/File. 

Note I stumbled into this in Win Env. and really don't know how it works in 
other platforms.

v1.0 code:
    public boolean accept(File dir, String name) {
        String filename = dir.getName() + File.separator + name;
        return accept(new File(filename));
    }

correct code should be:
    public boolean accept(File dir, String name) {
        String filename = dir.getPath() + File.separator + name;
        return accept(new File(filename));
    }

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message