[PATCH 1/2] libstdc++: Support UNC paths on MinGW in fs::path
Jonathan Wakely
jwakely.gcc@gmail.com
Sat May 10 13:09:16 GMT 2025
On Sat, 10 May 2025 at 12:49, Johannes Grunenberg
<johannes.grunenberg@stud.uni-hannover.de> wrote:
>
> UNC paths on Windows start with a root name "\\server" instead of a
> drive letter ("c:"). Support for parsing this was already implemented
> for cygwin, which (compared to MinGW) doesn't use backslash as the
> preferred separator.
> This mainly enables SLASHSLASH_IS_ROOTNAME on Windows and adjusts the
> tests accordingly.
> I aligned path::_M_append with path::operator/= to use has_root_directory
> and is_absolute from `this` instead of the appended path. Note that
> before this patch, `is_absolute && has_root_directory` was always
> `false`, as is_absolute implied has_root_directory. This isn't the case
> anymore (e.g. `\\foo` doesn't have a root directory).
>
> PR libstdc++-v3/99333
> PR libstdc++-v3/99430
> PR libstdc++-v3/106127
>
> libstdc++-v3/ChangeLog:
>
> * config/abi/pre/gnu.ver: Add fs::path::_M_is_unc_path() to ABI
> * include/bits/fs_path.h: Add and use fs::path::_M_is_unc_path()
> on Windows.
> * src/c++17/fs_path.cc (defined): Treat "//" as a root name on
> Windows.
> (path::_M_append): Align with operator/=.
> (path::_M_is_unc_path): Added helper to check for
> "(slash)(slash)(not-slash)".
> * testsuite/27_io/filesystem/path/append/path.cc: Added tests for UNC
> paths.
> * testsuite/27_io/filesystem/path/append/source.cc: Added tests for
> UNC paths.
> * testsuite/27_io/filesystem/path/decompose/filename.cc: Switched
> Windows FS to test for UNC paths.
> * testsuite/27_io/filesystem/path/decompose/root_directory.cc:
> Switched Windows FS to test for UNC paths.
> * testsuite/27_io/filesystem/path/generation/normal.cc: Switched
> Windows FS to test for UNC paths.
> * testsuite/27_io/filesystem/path/generic/94242.cc: Added case for
> double-slashes as root directories.
> * testsuite/27_io/filesystem/path/generic/generic_string.cc: Added
> case for double-slashes as root directories.
> * testsuite/27_io/filesystem/path/generic/utf.cc: Added case for
> double-slashes as root directories.
> * testsuite/27_io/filesystem/path/generic/wchar_t.cc: Added case for
> double-slashes as root directories.
> * testsuite/27_io/filesystem/path/itr/traversal.cc: Switched Windows
> FS to test for UNC paths.
> * testsuite/27_io/filesystem/path/query/is_absolute.cc: Test that UNC
> paths are absolute.
>
> Signed-off-by: Johannes Grunenberg <johannes.grunenberg@stud.uni-hannover.de>
Just to check, the Signed-off-by: trailer has a specific meaning which
is described at https://gcc.gnu.org/dco.html
Please confirm that you're using it that way (and not just adding it
because others do so).
I don't know much about UNC paths so this might take me a while to
review, but thanks for working on this and contributing the patches!
More information about the Libstdc++
mailing list