p-ranav / glob

Glob for C++17

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Magic Path" (`\\?\`) on windows does not work

helmesjo opened this issue · comments

The following snippet will not return the expected subdir:

// long path
auto dummy = std::filesystem::temp_directory_path() / "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooonooooooooog" / "dummy" / "dummy";
// prefix with the magic '\\?\' shenanigans
dummy = std::filesystem::path("\\\\?\\" + dummy.string());

// directory is created fine
auto errorCode = std::error_code{};
std::filesystem::create_directories(dummy, errorCode);
assert(!errorCode);

// but globbing fails to find any subdirs. Shortening the path makes it work
const auto matchingEntries = glob::glob(dummy.parent_path().string() + "/*");
assert (!matchingEntries.empty());