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

Reviewed-by: alanb, chegar
This commit is contained in:
Pavel Rappo 2014-04-29 13:23:08 +01:00 committed by Alan Bateman
parent 2db0164863
commit 5b2e62685a
3 changed files with 18 additions and 3 deletions

View File

@ -98,6 +98,7 @@ class WindowsConstants {
public static final int ERROR_DISK_FULL = 112; public static final int ERROR_DISK_FULL = 112;
public static final int ERROR_INSUFFICIENT_BUFFER = 122; public static final int ERROR_INSUFFICIENT_BUFFER = 122;
public static final int ERROR_INVALID_LEVEL = 124; 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_DIR_NOT_EMPTY = 145;
public static final int ERROR_ALREADY_EXISTS = 183; public static final int ERROR_ALREADY_EXISTS = 183;
public static final int ERROR_MORE_DATA = 234; public static final int ERROR_MORE_DATA = 234;

View File

@ -86,14 +86,28 @@ class WindowsFileStore
WindowsFileAttributes.get(file, true); WindowsFileAttributes.get(file, true);
target = file.getPathForWin32Calls(); target = file.getPathForWin32Calls();
} }
String root = GetVolumePathName(target); try {
return new WindowsFileStore(root); 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) { } catch (WindowsException x) {
x.rethrowAsIOException(file); x.rethrowAsIOException(file);
return null; // keep compiler happy return null; // keep compiler happy
} }
} }
private static WindowsFileStore createFromPath(String target) throws WindowsException {
String root = GetVolumePathName(target);
return new WindowsFileStore(root);
}
VolumeInformation volumeInformation() { VolumeInformation volumeInformation() {
return volInfo; return volInfo;
} }

View File

@ -66,7 +66,7 @@ class WindowsLinkSupport {
* Returns the final path (all symbolic links resolved) or null if this * Returns the final path (all symbolic links resolved) or null if this
* operation is not supported. * operation is not supported.
*/ */
private static String getFinalPath(WindowsPath input) throws IOException { static String getFinalPath(WindowsPath input) throws IOException {
long h = 0; long h = 0;
try { try {
h = input.openForReadAttributeAccess(true); h = input.openForReadAttributeAccess(true);