提交 6c74ebbe 编写于 作者: A alanb

8034057: Files.getFileStore and Files.isWritable do not work with SUBST'ed drives (win)

Reviewed-by: alanb, chegar
Contributed-by: pavel.rappo@oracle.com
上级 f436e0fc
......@@ -98,6 +98,7 @@ class WindowsConstants {
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;
......
......@@ -86,14 +86,28 @@ class WindowsFileStore
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;
}
......
......@@ -66,7 +66,7 @@ class WindowsLinkSupport {
* 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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册