Resolve only symlinks and junctions on Windows

This commit is contained in:
Roman Shevchenko
2012-12-12 13:26:22 +01:00
parent d672b4b8fc
commit b35e67781b
5 changed files with 10 additions and 2 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -108,7 +108,8 @@ JNIEXPORT jstring JNICALL Java_com_intellij_openapi_util_io_win32_IdeaWin32_reso
if (h != INVALID_HANDLE_VALUE) {
FindClose(h);
if (IS_SET(data.dwFileAttributes, FILE_ATTRIBUTE_REPARSE_POINT)) {
if (IS_SET(data.dwFileAttributes, FILE_ATTRIBUTE_REPARSE_POINT) &&
(IS_SET(data.dwReserved0, IO_REPARSE_TAG_SYMLINK) || IS_SET(data.dwReserved0, IO_REPARSE_TAG_MOUNT_POINT))) {
HANDLE th = CreateFileW(winPath, 0, FILE_SHARE_ATTRIBUTES, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (th != INVALID_HANDLE_VALUE) {
wchar_t buff[MAX_PATH], * finalPath = buff;

View File

@@ -307,6 +307,13 @@ public class FileAttributesReadingTest {
final FileAttributes attributes = getAttributes(substRoot);
assertEquals(FileAttributes.Type.DIRECTORY, attributes.type);
assertDirectoriesEqual(substRoot);
final File[] children = substRoot.listFiles();
assertNotNull(children);
assertEquals(1, children.length);
final File file = children[0];
final String target = FileSystemUtil.resolveSymLink(file);
assertEquals(file.getPath(), target);
}
finally {
IoTestUtil.deleteSubst(substRoot.getPath());

View File

@@ -115,7 +115,7 @@ public class IoTestUtil {
final int res = runCommand(command);
assertEquals(command.command().toString(), 0, res);
final File rootFile = new File(substRoot);
final File rootFile = new File(substRoot + "\\");
assertTrue("target=" + target + ", subst=" + rootFile, rootFile.isDirectory());
return rootFile;
}