ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/util FileUtilsTest.java
Date Mon, 10 Jun 2002 06:19:32 GMT
bodewig     2002/06/09 23:19:32

  Modified:    src/main/org/apache/tools/ant/util FileUtils.java
               src/testcases/org/apache/tools/ant/util FileUtilsTest.java
  Log:
  Merge over a bug-fix needed to get jakarta-tomcat built by Gump.
  
  Revision  Changes    Path
  1.27      +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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- FileUtils.java	1 Jun 2002 12:26:42 -0000	1.26
  +++ FileUtils.java	10 Jun 2002 06:19:32 -0000	1.27
  @@ -95,7 +95,7 @@
    * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a>
    * @author <a href="mailto:jtulley@novell.com">Jeff Tulley</a> 
    *
  - * @version $Revision: 1.26 $
  + * @version $Revision: 1.27 $
    */
   
   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;
           }
  
  
  
  1.11      +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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- FileUtilsTest.java	1 Jun 2002 12:26:43 -0000	1.10
  +++ FileUtilsTest.java	10 Jun 2002 06:19:32 -0000	1.11
  @@ -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:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message