From 9557aed0f00650ea6cda33e994893e5e3f3faf4f Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Fri, 2 Apr 2004 20:20:43 +0000 Subject: [PATCH] UNC pathnames did not work for ANT_HOME or -lib locations on Windows. PR: 27922 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276275 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 3 +++ .../org/apache/tools/ant/launch/Locator.java | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index d621d3921..c9cc43c3d 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -26,6 +26,9 @@ Fixed bugs: * I/O-intensive processes hung when executed via . Bugzilla reports 23893/26852. +* UNC pathnames did not work for ANT_HOME or -lib locations on Windows. + Bugzilla report 27922. + Other changes: -------------- diff --git a/src/main/org/apache/tools/ant/launch/Locator.java b/src/main/org/apache/tools/ant/launch/Locator.java index 6f158f43d..97e5d94d5 100644 --- a/src/main/org/apache/tools/ant/launch/Locator.java +++ b/src/main/org/apache/tools/ant/launch/Locator.java @@ -101,13 +101,18 @@ public final class Locator { * @since Ant 1.6 */ public static String fromURI(String uri) { - if (!uri.startsWith("file:")) { - throw new IllegalArgumentException("Can only handle file: URIs"); - } - if (uri.startsWith("file://")) { - uri = uri.substring(7); - } else { - uri = uri.substring(5); + try { + URL url = new URL(uri); + if (!("file".equals(url.getProtocol()))) { + throw new IllegalArgumentException("Can only handle file: URIs"); + } + StringBuffer buf = new StringBuffer(url.getHost()); + if (buf.length() > 0) { + buf.insert(0, "//"); + } + buf.append(url.getPath()); + uri = buf.toString(); + } catch (MalformedURLException emYouEarlEx) { } uri = uri.replace('/', File.separatorChar);