bodewig 2002/06/05 02:23:51
Modified: src/main/org/apache/tools/ant/util Tag: ANT_15_BRANCH
FileUtils.java
src/testcases/org/apache/tools/ant/util Tag: ANT_15_BRANCH
FileUtilsTest.java
Log:
FileUtils#removeLeadingPath would return "bar" if asked to remove
"/foo" from "/foobar" which is not what it is intended to do (and
causes a Gump failure for Tomcat right now).
Revision Changes Path
No revision
No revision
1.25.2.4 +7 -7
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.25.2.3
retrieving revision 1.25.2.4
diff -u -r1.25.2.3 -r1.25.2.4
--- FileUtils.java 28 May 2002 06:13:10 -0000 1.25.2.3
+++ FileUtils.java 5 Jun 2002 09:23:51 -0000 1.25.2.4
@@ -95,7 +95,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Magesh Umasankar</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jeff Tulley</a>
*
- * @version $Revision: 1.25.2.3 $
+ * @version $Revision: 1.25.2.4 $
*/
public class FileUtils {
@@ -866,14 +866,14 @@
* @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;
}
No revision
No revision
1.9.2.2 +2 -0
jakarta-ant/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java
Index: FileUtilsTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java,v
retrieving revision 1.9.2.1
retrieving revision 1.9.2.2
diff -u -r1.9.2.1 -r1.9.2.2
--- FileUtilsTest.java 28 May 2002 06:13:11 -0000 1.9.2.1
+++ FileUtilsTest.java 5 Jun 2002 09:23:51 -0000 1.9.2.2
@@ -404,6 +404,8 @@
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")));
}
/**
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>