I'm using C++17's std::filesystem::absolute to convert relative paths to absolute ones. I noticed that on Windows (MSVC), this function seems to resolve . and .. components in the path, but on Linux (GCC/libstdc++), these components remain in the result.
For example, if my current directory is /home/user (or C:\Users on Windows):
std::filesystem::path rel = "foo/./bar/child/..";
auto abs = std::filesystem::absolute(rel);
On Windows, I get: C:\Users\foo\bar
On Linux, I get: /home/user/foo/./bar/child/..
Is this platform-dependent behavior expected according to the C++ standard?
//SOMESERVER/SOMESHARE/...should also not be flattened to/SOMESERVER/SOMESHAREas on Linux, because it completely changes the semantics.std::filesystem::canonicalif you want to make paths as simple as possible. Note that it expects the path to exist, which is not the case forabsolute.foo/../barmight not be equivalent tobar, I don't see howfoo/./barcan lead to different path thanfoo/bar.....is not resolved on Posix, but your example shows that it is.