From 5e4d3d0c93a57c8ead35236c6e444d78897f427f Mon Sep 17 00:00:00 2001 From: Antoine Levy-Lambert Date: Wed, 15 Nov 2006 11:33:43 +0000 Subject: [PATCH] do not uppercase systematically drive letters in FileUtils#normalize append drive letter to absolute paths in Locator#fromURI make FileUtilsTest pass under JDK 1.3 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@475206 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 7 +++++++ src/main/org/apache/tools/ant/launch/Locator.java | 5 +++++ src/main/org/apache/tools/ant/util/FileUtils.java | 2 +- .../org/apache/tools/ant/util/FileUtilsTest.java | 15 +++++++++++---- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index fe809e29c..c0afb83e6 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -32,6 +32,13 @@ Other changes: * add quiet attribute to loadfile/resource. Bugzilla 38249. +* make Locator#fromURI also append the drive letter when running under Windows + with JDK 1.3 or 1.2 + +* do not uppercase the drive letters systematically in FileUtils#normalize + + + Changes from Ant 1.7.0Beta3 to Ant 1.7.0RC1 =========================================== diff --git a/src/main/org/apache/tools/ant/launch/Locator.java b/src/main/org/apache/tools/ant/launch/Locator.java index 282b76a56..9727de9ec 100644 --- a/src/main/org/apache/tools/ant/launch/Locator.java +++ b/src/main/org/apache/tools/ant/launch/Locator.java @@ -207,6 +207,11 @@ public final class Locator { String path = null; try { path = decodeUri(uri); + String cwd = System.getProperty("user.dir"); + int posi = cwd.indexOf(":"); + if ((posi > 0) && path.startsWith(File.separator)) { + path = cwd.substring(0, posi + 1) + path; + } } catch (UnsupportedEncodingException exc) { // not sure whether this is clean, but this method is // declared not to throw exceptions. diff --git a/src/main/org/apache/tools/ant/util/FileUtils.java b/src/main/org/apache/tools/ant/util/FileUtils.java index a31ae6f53..2aabcf47f 100644 --- a/src/main/org/apache/tools/ant/util/FileUtils.java +++ b/src/main/org/apache/tools/ant/util/FileUtils.java @@ -726,7 +726,7 @@ public class FileUtils { if (colon > 0 && (onDos || onNetWare)) { int next = colon + 1; - root = path.substring(0, next).toUpperCase(); + root = path.substring(0, next); char[] ca = path.toCharArray(); root += sep; //remove the initial separator; the root has it. diff --git a/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java b/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java index e1f4092e6..ae8ee05b4 100644 --- a/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java @@ -124,9 +124,9 @@ public class FileUtilsTest extends TestCase { assertEquals(driveSpec + "\\", FILE_UTILS.resolveFile(null, driveSpec + "\\").getPath()); String driveSpecLower = "c:"; - assertEquals(driveSpec + "\\", + assertEquals(driveSpecLower + "\\", FILE_UTILS.resolveFile(null, driveSpecLower + "/").getPath()); - assertEquals(driveSpec + "\\", + assertEquals(driveSpecLower + "\\", FILE_UTILS.resolveFile(null, driveSpecLower + "\\").getPath()); /* * promised to eliminate consecutive slashes after drive letter. @@ -237,9 +237,9 @@ public class FileUtilsTest extends TestCase { assertEquals(driveSpec + "\\", FILE_UTILS.normalize(driveSpec + "\\").getPath()); String driveSpecLower = "c:"; - assertEquals(driveSpec + "\\", + assertEquals(driveSpecLower + "\\", FILE_UTILS.normalize(driveSpecLower + "/").getPath()); - assertEquals(driveSpec + "\\", + assertEquals(driveSpecLower + "\\", FILE_UTILS.normalize(driveSpecLower + "\\").getPath()); /* * promised to eliminate consecutive slashes after drive letter. @@ -492,6 +492,13 @@ public class FileUtilsTest extends TestCase { return uri; } } + + public void testIsContextRelativePath() { + if (Os.isFamily("dos")) { + assertTrue(FileUtils.isContextRelativePath("/\u00E4nt")); + assertTrue(FileUtils.isContextRelativePath("\\foo")); + } + } /** * test fromUri */