-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std::fs::canonicalize uses GetFinalPathNameByHandleW, which can fail #79449
Comments
According to http://mail.openjdk.java.net/pipermail/core-libs-dev/2020-July/067594.html,
This references another virtual disk tool called ImDisk which creates a Ram disk. The code at https://docs.microsoft.com/en-us/windows/win32/memory/obtaining-a-file-name-from-a-file-handle shows an example of using Edit: |
This is a fairly well known problem, #59117 discusses some of the problems along with links to many other issues. Another option I have considered is using It would be nice if |
Triage: This seems a like a duplicate to #48249 in practice, so closing as such. |
I was just testing out the Win32 function
GetFinalPathNameByHandleW
, and saw a case where it failed to work.Steps to reproduce:
CreateFileW
on a file on the disk image (my path: "X:/flash Movies/11-29-04-thanksgiving.swf")GetFinalPathNameByHandleW
on that handle, usingFILE_NAME_NORMALIZED
Function returns 0 instead of returning a path name, and
GetLastError
returns 1 (ERROR_INVALID_FUNCTION
).However, if I call
GetFinalPathNameByHandleW
usingVOLUME_NAME_NT
, I get something: "\Device\OSFMDisk0\Flash Movies\11-29-04-thanksgiving.swf", but this path isn't usable withCreateFileW
.There are alternative ways to canonicalize a filename on Win32:
PathCanonicalizeW
is the traditional way to do it, works on Windows 2000 and later, but it is limited to 260 character filenames, and is marked as deprecated by Microsoft.PathCchCanonicalizeEx
is the replacement function since Windows 8, and is unavailable in Windows 7 and earlier, but does support very long path names.The text was updated successfully, but these errors were encountered: