8034057: Files.getFileStore and Files.isWritable do not work with SUBST'ed drives (win)
Reviewed-by: alanb, chegar
Contributed-by: pavel.rappo@oracle.com
--- a/jdk/src/windows/classes/sun/nio/fs/WindowsConstants.java Tue Apr 29 11:15:21 2014 +0200
+++ b/jdk/src/windows/classes/sun/nio/fs/WindowsConstants.java Tue Apr 29 13:23:08 2014 +0100
@@ -98,6 +98,7 @@
public static final int ERROR_DISK_FULL = 112;
public static final int ERROR_INSUFFICIENT_BUFFER = 122;
public static final int ERROR_INVALID_LEVEL = 124;
+ public static final int ERROR_DIR_NOT_ROOT = 144;
public static final int ERROR_DIR_NOT_EMPTY = 145;
public static final int ERROR_ALREADY_EXISTS = 183;
public static final int ERROR_MORE_DATA = 234;
--- a/jdk/src/windows/classes/sun/nio/fs/WindowsFileStore.java Tue Apr 29 11:15:21 2014 +0200
+++ b/jdk/src/windows/classes/sun/nio/fs/WindowsFileStore.java Tue Apr 29 13:23:08 2014 +0100
@@ -86,14 +86,28 @@
WindowsFileAttributes.get(file, true);
target = file.getPathForWin32Calls();
}
- String root = GetVolumePathName(target);
- return new WindowsFileStore(root);
+ try {
+ return createFromPath(target);
+ } catch (WindowsException e) {
+ if (e.lastError() != ERROR_DIR_NOT_ROOT)
+ throw e;
+ target = WindowsLinkSupport.getFinalPath(file);
+ if (target == null)
+ throw new FileSystemException(file.getPathForExceptionMessage(),
+ null, "Couldn't resolve path");
+ return createFromPath(target);
+ }
} catch (WindowsException x) {
x.rethrowAsIOException(file);
return null; // keep compiler happy
}
}
+ private static WindowsFileStore createFromPath(String target) throws WindowsException {
+ String root = GetVolumePathName(target);
+ return new WindowsFileStore(root);
+ }
+
VolumeInformation volumeInformation() {
return volInfo;
}
--- a/jdk/src/windows/classes/sun/nio/fs/WindowsLinkSupport.java Tue Apr 29 11:15:21 2014 +0200
+++ b/jdk/src/windows/classes/sun/nio/fs/WindowsLinkSupport.java Tue Apr 29 13:23:08 2014 +0100
@@ -66,7 +66,7 @@
* Returns the final path (all symbolic links resolved) or null if this
* operation is not supported.
*/
- private static String getFinalPath(WindowsPath input) throws IOException {
+ static String getFinalPath(WindowsPath input) throws IOException {
long h = 0;
try {
h = input.openForReadAttributeAccess(true);