Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@jakarta.apache.org Received: (qmail 25526 invoked by uid 500); 1 Oct 2001 13:34:33 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: ant-dev@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 25478 invoked by uid 500); 1 Oct 2001 13:34:32 -0000 Delivered-To: apmail-jakarta-ant-cvs@apache.org Date: 1 Oct 2001 13:32:36 -0000 Message-ID: <20011001133236.34521.qmail@icarus.apache.org> From: bodewig@apache.org To: jakarta-ant-cvs@apache.org Subject: cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/util FileUtilsTest.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N bodewig 01/10/01 06:32:36 Modified: src/main/org/apache/tools/ant/util FileUtils.java SourceFileScanner.java src/testcases/org/apache/tools/ant/util FileUtilsTest.java Log: Make FileUtils.resolveFile more robust - modelled after File(File, String). This avoids the explicit checks for null directories in SourceFileScanner as well. Revision Changes Path 1.5 +10 -1 jakarta-ant/src/main/org/apache/tools/ant/util/FileUtils.java Index: FileUtils.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/util/FileUtils.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- FileUtils.java 2001/08/18 14:59:40 1.4 +++ FileUtils.java 2001/10/01 13:32:36 1.5 @@ -299,7 +299,9 @@ * @param file the "reference" file for relative paths. This * instance must be an absolute file and must not contain * "./" or "../" sequences (same for \ instead - * of /). + * of /). If it is null, this call is equivalent to + * new java.io.File(filename). + * * @param filename a file name * * @return an absolute file that doesn't contain "./" or @@ -327,6 +329,10 @@ return normalize(filename); } + if (file == null) { + return new File(filename); + } + File helpFile = new File(file.getAbsolutePath()); StringTokenizer tok = new StringTokenizer(filename, File.separator); while (tok.hasMoreTokens()) { @@ -361,6 +367,9 @@ *
  • DOS style paths that start with a drive letter will have * \ as the separator.
  • * + * + * @throws java.lang.NullPointerException if the file path is + * equal to null. */ public File normalize(String path) { String orig = path; 1.8 +2 -12 jakarta-ant/src/main/org/apache/tools/ant/util/SourceFileScanner.java Index: SourceFileScanner.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/util/SourceFileScanner.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- SourceFileScanner.java 2001/10/01 07:44:42 1.7 +++ SourceFileScanner.java 2001/10/01 13:32:36 1.8 @@ -121,12 +121,7 @@ continue; } - File src = null; - if (srcDir == null) { - src = new File(files[i]); - } else { - src = fileUtils.resolveFile(srcDir, files[i]); - } + File src = fileUtils.resolveFile(srcDir, files[i]); if (src.lastModified() > now) { task.log("Warning: "+files[i]+" modified in the future.", @@ -136,12 +131,7 @@ boolean added = false; targetList.setLength(0); for (int j=0; !added && j