|
@@ -97,7 +97,7 @@ class Globber {
|
|
|
/**
|
|
|
* Translate an absolute path into a list of path components.
|
|
|
* We merge double slashes into a single slash here.
|
|
|
- * The first path component (i.e. root) does not get an entry in the list.
|
|
|
+ * POSIX root path, i.e. '/', does not get an entry in the list.
|
|
|
*/
|
|
|
private static List<String> getPathComponents(String path)
|
|
|
throws IOException {
|
|
@@ -167,8 +167,8 @@ class Globber {
|
|
|
// Get the absolute path for this flattened pattern. We couldn't do
|
|
|
// this prior to flattening because of patterns like {/,a}, where which
|
|
|
// path you go down influences how the path must be made absolute.
|
|
|
- Path absPattern =
|
|
|
- fixRelativePart(new Path(flatPattern .isEmpty() ? "." : flatPattern ));
|
|
|
+ Path absPattern = fixRelativePart(new Path(
|
|
|
+ flatPattern.isEmpty() ? Path.CUR_DIR : flatPattern));
|
|
|
// Now we break the flattened, absolute pattern into path components.
|
|
|
// For example, /a/*/c would be broken into the list [a, *, c]
|
|
|
List<String> components =
|
|
@@ -176,9 +176,19 @@ class Globber {
|
|
|
// Starting out at the root of the filesystem, we try to match
|
|
|
// filesystem entries against pattern components.
|
|
|
ArrayList<FileStatus> candidates = new ArrayList<FileStatus>(1);
|
|
|
- candidates.add(new FileStatus(0, true, 0, 0, 0,
|
|
|
- new Path(scheme, authority, "/")));
|
|
|
-
|
|
|
+ if (Path.WINDOWS && !components.isEmpty()
|
|
|
+ && Path.isWindowsAbsolutePath(absPattern.toUri().getPath(), true)) {
|
|
|
+ // On Windows the path could begin with a drive letter, e.g. /E:/foo.
|
|
|
+ // We will skip matching the drive letter and start from listing the
|
|
|
+ // root of the filesystem on that drive.
|
|
|
+ String driveLetter = components.remove(0);
|
|
|
+ candidates.add(new FileStatus(0, true, 0, 0, 0, new Path(scheme,
|
|
|
+ authority, Path.SEPARATOR + driveLetter + Path.SEPARATOR)));
|
|
|
+ } else {
|
|
|
+ candidates.add(new FileStatus(0, true, 0, 0, 0,
|
|
|
+ new Path(scheme, authority, Path.SEPARATOR)));
|
|
|
+ }
|
|
|
+
|
|
|
for (String component : components) {
|
|
|
ArrayList<FileStatus> newCandidates =
|
|
|
new ArrayList<FileStatus>(candidates.size());
|