A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/microsoft/STL/issues/2256 below:

lexically_relative() can not handle long path with prefix \\?\ · Issue #2256 · microsoft/STL · GitHub

Describe the bug
I would expect that this line of code is true:
std::filesystem::path("\\\\?\\C:\\a\\d").lexically_relative("\\\\?\\C:\\a") == "d"
But it is not, because an empty string will be returned. The reason for that is, that inside of lexically_relative() a check _Relative_path_contains_root_name() will be executed, but this is always true. The reason is how the filesystem is handling the root name as explained in _Find_root_name_end(). There is pointed out, that in my case \\?\ is the root name. But at the same time, the path contains C:\ which is a valid root name as well. Because of that, we have the weird behaving, that:
std::filesystem::path("\\\\?\\C:\\a\\d").relative_path() == "C:\\a\\d") which is not a relative path and causes the misbehaving of lexically_relative, because it can find another root_name inside of the "relative" path.

Command-line test case

#include <iostream>
#include <filesystem>
#include <cassert>
namespace fs = std::filesystem;
 
int main()
{
    assert(fs::path("C:\\a\\d").lexically_relative("C:\\a") == "d");
}

Expected behavior
That \\?\C:\ will be treated as root path and not \\?\

STL version

Additional context
In another issue #1921 StephanTLavavej pointed out, that \\?\ only should be used by expert users and I agree. But in case I want to use the new Desktop-Bridge I had to use the new manifest appxmanifest, which not has a property anymore longPathAware. So I don't know how my app gives the consence of supporting that. (Is there maybe a better way to opt-in to the long path app wise) And I don't find any documentation for this use case, besides https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd. And so my only solution to solve this issue is, of converting the paths with the prefix \\?\. But this from my point of view is not well handled by the std::filesystem lib.

ridilculous and BillyONeal


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4