tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@locus.apache.org
Subject cvs commit: jakarta-tools/ant/src/main/org/apache/tools/ant Project.java
Date Mon, 13 Dec 1999 20:02:51 GMT
rubys       99/12/13 12:02:51

  Modified:    ant/src/main/org/apache/tools/ant Project.java
  Log:
  "Borrow" some Windows specific path cleanup logic from
  jakarta-tomcat\src\share\org\apache\tomcat\util\FileUtil.java
  
  Revision  Changes    Path
  1.20      +29 -2     jakarta-tools/ant/src/main/org/apache/tools/ant/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tools/ant/src/main/org/apache/tools/ant/Project.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Project.java	1999/12/12 22:06:01	1.19
  +++ Project.java	1999/12/13 20:02:50	1.20
  @@ -371,8 +371,35 @@
       public File resolveFile(String fileName) {
   	// deal with absolute files
   	if (fileName.startsWith("/")) return new File( fileName );
  -	if (System.getProperty("os.name").toLowerCase().startsWith("windows"))
  -	    if (fileName.indexOf(":\\")==1) return new File( fileName );
  +
  +        // Eliminate consecutive slashes after the drive spec
  +        if (fileName.length() >= 2 &&
  +            Character.isLetter(fileName.charAt(0)) &&
  +            fileName.charAt(1) == ':') {
  +            char[] ca = fileName.replace('/', '\\').toCharArray();
  +            char c;
  +            StringBuffer sb = new StringBuffer();
  +
  +            for (int i = 0; i < ca.length; i++) {
  +                if ((ca[i] != '\\') ||
  +                    (ca[i] == '\\' &&
  +                        i > 0 &&
  +                        ca[i - 1] != '\\')) {
  +                    if (i == 0 &&
  +                        Character.isLetter(ca[i]) &&
  +                        i < ca.length - 1 &&
  +                        ca[i + 1] == ':') {
  +                        c = Character.toUpperCase(ca[i]);
  +                    } else {
  +                        c = ca[i];
  +                    }
  +
  +                    sb.append(c);
  +                }
  +            }
  +
  +            return new File(sb.toString());
  +        }
   
   	File file = new File(baseDir.getAbsolutePath());
   	StringTokenizer tok = new StringTokenizer(fileName, "/", false);
  
  
  

Mime
View raw message