mbenson     2004/04/23 07:33:33

  Modified:    src/main/org/apache/tools/ant/launch Tag: ANT_16_BRANCH
                        Locator.java
               .        Tag: ANT_16_BRANCH WHATSNEW
  Log:
  Merge fix for Windows UNC pathnames.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.6.2.7   +16 -7     ant/src/main/org/apache/tools/ant/launch/Locator.java
  
  Index: Locator.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/launch/Locator.java,v
  retrieving revision 1.6.2.6
  retrieving revision 1.6.2.7
  diff -u -r1.6.2.6 -r1.6.2.7
  --- Locator.java      21 Apr 2004 07:19:13 -0000      1.6.2.6
  +++ Locator.java      23 Apr 2004 14:33:33 -0000      1.6.2.7
  @@ -102,16 +102,25 @@
        * @since Ant 1.6
        */
       public static String fromURI(String uri) {
  -        if (!uri.startsWith("file:")) {
  -            throw new IllegalArgumentException("Can only handle file: URIs");
  +        URL url = null;
  +        try {
  +            url = new URL(uri);
  +        } catch (MalformedURLException emYouEarlEx) {
           }
  -        if (uri.startsWith("file://")) {
  -            uri = uri.substring(7);
  -        } else {
  -            uri = uri.substring(5);
  +        if (url == null || !("file".equals(url.getProtocol()))) {
  +            throw new IllegalArgumentException("Can only handle valid file: 
URIs");
           }
  +        StringBuffer buf = new StringBuffer(url.getHost());
  +        if (buf.length() > 0) {
  +            buf.insert(0, File.separatorChar).insert(0, File.separatorChar);
  +        }
  +
  +        String file = url.getFile();
  +        int queryPos = file.indexOf('?');
  +        buf.append((queryPos < 0) ? file : file.substring(0, queryPos));
  +
  +        uri = buf.toString().replace('/', File.separatorChar);
   
  -        uri = uri.replace('/', File.separatorChar);
           if (File.pathSeparatorChar == ';' && uri.startsWith("\\") && 
uri.length() > 2
               && Character.isLetter(uri.charAt(1)) && uri.lastIndexOf(':') > 
-1) {
               uri = uri.substring(1);
  
  
  
  No                   revision
  No                   revision
  1.503.2.81 +6 -3      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.503.2.80
  retrieving revision 1.503.2.81
  diff -u -r1.503.2.80 -r1.503.2.81
  --- WHATSNEW  23 Apr 2004 14:19:09 -0000      1.503.2.80
  +++ WHATSNEW  23 Apr 2004 14:33:33 -0000      1.503.2.81
  @@ -61,11 +61,16 @@
   * Ant failed to locate tools.jar if the jre directory name wasn't all
     lowercase.  Bugzilla Report 25798.
   
  - * Redirector exhibited inconsistent behavior with regard to split
  +* Redirector exhibited inconsistent behavior with regard to split
      output.  When sent to file only, files would be created in all
      cases; when split file-property, files were only created if
      writes were performed.
   
  +* fixed case handling of scriptdef attributes and elements.
  +
  +* UNC pathnames did not work for ANT_HOME or -lib locations on Windows.
  +  Bugzilla report 27922.
  +
   Other changes:
   --------------
   
  @@ -148,8 +153,6 @@
   * wrong compare used in ProjectComponent for logging. Bugzilla Report 28070.
   
   * failOnAny attribute for <parallel> was broken. Bugzilla Report 28122.
  -
  -* fixed case handling of scriptdef attributes and elements.
   
   Other changes:
   --------------
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to