Browse Source

Merge over a bug-fix needed to get jakarta-tomcat built by Gump.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272855 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
f40cbc60b3
2 changed files with 8 additions and 6 deletions
  1. +6
    -6
      src/main/org/apache/tools/ant/util/FileUtils.java
  2. +2
    -0
      src/testcases/org/apache/tools/ant/util/FileUtilsTest.java

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

@@ -866,14 +866,14 @@ public class FileUtils {
* @since Ant 1.5
*/
public String removeLeadingPath(File leading, File path) {
String l = normalize(leading.getAbsolutePath()).getAbsolutePath();
// if leading's path ends with a slash, it will be stripped by
// normalize - we always add one so we never think /foo was a
// parent directory of /foobar
String l = normalize(leading.getAbsolutePath()).getAbsolutePath()
+ File.separator;
String p = normalize(path.getAbsolutePath()).getAbsolutePath();
if (p.startsWith(l)) {
String result = p.substring(l.length());
if (result.startsWith(File.separator)) {
result = result.substring(File.separator.length());
}
return result;
return p.substring(l.length());
} else {
return p;
}


+ 2
- 0
src/testcases/org/apache/tools/ant/util/FileUtilsTest.java View File

@@ -404,6 +404,8 @@ public class FileUtilsTest extends TestCase {
new File("c:\\foo\\bar")));
assertEquals(fu.normalize("/bar").getAbsolutePath(),
fu.removeLeadingPath(new File("/foo"), new File("/bar")));
assertEquals(fu.normalize("/foobar").getAbsolutePath(),
fu.removeLeadingPath(new File("/foo"), new File("/foobar")));
}

/**


Loading…
Cancel
Save