-
Notifications
You must be signed in to change notification settings - Fork 166
Description
Currently I'm unable to call weakly_canonical()
with a long path on Windows. Long path in this context means the Microsoft Windows extension described at https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation. A path can be prefixed by \\?\
and then can have more than 260 characters (with a number of restrictions).
I could trace the problem of using long paths in weakly_canonical()
to the method create_file_handle()
in
filesystem/src/windows_tools.hpp
Line 259 in ea22e76
return ::CreateFileW(p.c_str(), dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); |
This is called via:
Line 4437 in ea22e76
file_status head_status = detail::status_impl(head, &local_ec); |
But the call fails for long paths. Since in weakly_canonical()
, the handle is only needed for the root item, I could work around this by adding some extra handling to create_file_handle()
. My added logic is:
- If the given path has a long-path prefix but is less than 260 characters long, remove the long path prefix and rely on Windows to do the right thing.
Is that reasonable, and could something like this be added to the library?