Commit 0d28d64b authored by mevenson@1c010e3e-69d0-11dd-93a8-456734b0d56f's avatar mevenson@1c010e3e-69d0-11dd-93a8-456734b0d56f
Browse files

Fix Uniform Naming Convention (aka "UNC" or "network") paths under Windows.

DIRECTORY now works again on UNC paths.

UNC paths may be either specified with either back slash (#\\) or
forward slash (#\/) doubled as the first character in a Pathname
namestring.

The patterns in

        //<server>/<share>/[directories-and-files]

are parsed as

    <server> is stored as HOST.

    <share> is stored as DEVICE.

    [directories-and-files] gets parsed as per the normal rules under
    Windows.

Mixing namestrings with both backslash and slash characters can lead
to unpredictable results.  It is recommended not to use backslash
characters in namestrings if it can be avoided.  The pathname printed
representation is always normalized to using forward slash delimiters.
parent 7b83d272
......@@ -242,13 +242,19 @@ public class Pathname extends LispObject {
return;
}
if (Utilities.isPlatformWindows) {
if (s.startsWith("\\\\")) { // XXX What if string starts with '//'?
//UNC path support
if (s.startsWith("\\\\") || s.startsWith("//")) {
// UNC path support
int shareIndex;
int dirIndex;
// match \\<server>\<share>\[directories-and-files]
int shareIndex = s.indexOf('\\', 2);
int dirIndex = s.indexOf('\\', shareIndex + 1);
if (s.startsWith("\\\\")) {
shareIndex = s.indexOf('\\', 2);
dirIndex = s.indexOf('\\', shareIndex + 1);
// match //<server>/<share>/[directories-and-files]
} else {
shareIndex = s.indexOf('/', 2);
dirIndex = s.indexOf('/', shareIndex + 1);
}
if (shareIndex == -1 || dirIndex == -1) {
error(new LispError("Unsupported UNC path format: \"" + s + '"'));
}
......@@ -651,8 +657,8 @@ public class Pathname extends LispObject {
sb.append(host.getStringValue());
sb.append(':');
} else {
// UNC paths now use unprintable representation
return null;
// A UNC path
sb.append("//").append(host.getStringValue()).append("/");
}
}
boolean uriEncoded = false;
......
......@@ -121,9 +121,15 @@ error to its caller."
(let ((namestring (directory-namestring pathname)))
(when (and namestring (> (length namestring) 0))
(when (featurep :windows)
(let ((device (pathname-device pathname)))
(when device
(setq namestring (concatenate 'string device ":" namestring)))))
(let ((host (pathname-host pathname))
(device (pathname-device pathname)))
(cond
((and host device)
(setq namestring
(concatenate 'string "//" host "/" device namestring)))
(device
(setq namestring
(concatenate 'string device ":" namestring))))))
(let ((entries (list-directories-with-wildcards
namestring nil resolve-symlinks))
(matching-entries ()))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment