Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
os: Symbolic links to empty directories broken on Windows #13658
Opening a symlink pointing to an empty directory fails - os.Open returns nil,nil.
On Windows opening a directory ends up in file_windows.go openDir function. If the directory is empty then ERROR_FILE_NOT_FOUND is returned and it goes to the if brances. Then syscall.GetFileAttributesEx is called.
However GetFileAttributesEx is like Lstat - not Stat.
As per https://msdn.microsoft.com/en-us/library/windows/desktop/aa365682%28v=vs.85%29.aspx#getfileattributes "If the path points to a symbolic link, the function returns attributes for the symbolic link.".
I don't understand what the problem is. I run this test:
and it succeeds. Why?
Looking at this further:
Windows symlinks are typed.
I.e. 1) Create a symlink to a non-directory, 2) target is deleted, and there is now an empty directory, 3) target file system thinks this is fine, 4) Symlink now should point to a directory and try to open it -> everything fails.
This seems like a limitation in Windows, closing it.