Browse Source

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
master
Antoine Levy-Lambert 18 years ago
parent
commit
5e4d3d0c93
4 changed files with 24 additions and 5 deletions
  1. +7
    -0
      WHATSNEW
  2. +5
    -0
      src/main/org/apache/tools/ant/launch/Locator.java
  3. +1
    -1
      src/main/org/apache/tools/ant/util/FileUtils.java
  4. +11
    -4
      src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java

+ 7
- 0
WHATSNEW View File

@@ -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
===========================================



+ 5
- 0
src/main/org/apache/tools/ant/launch/Locator.java View File

@@ -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.


+ 1
- 1
src/main/org/apache/tools/ant/util/FileUtils.java View File

@@ -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.


+ 11
- 4
src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java View File

@@ -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
*/


Loading…
Cancel
Save