From 6649653be9a33804e195a799895ead0b3436b2bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Sch=C3=BCmann?= Date: Fri, 9 Oct 2020 23:57:54 +0200 Subject: [PATCH] Extended path prefix handling on Windows. --- include/ghc/filesystem.hpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index 8ac2a86..7c9d78d 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -1654,12 +1654,17 @@ GHC_INLINE void path::postprocess_path_with_format(path::impl_string_type& p, pa #ifdef GHC_OS_WINDOWS case path::auto_format: case path::native_format: - if (detail::startsWith(p, std::string("\\\\?\\"))) { - // remove Windows long filename marker - p.erase(0, 4); - if (detail::startsWith(p, std::string("UNC\\"))) { - p.erase(0, 2); - p[0] = '\\'; + if (p.length() > 4 && p[2] == '?') { + if (detail::startsWith(p, std::string("\\\\?\\"))) { + // remove Windows long filename marker + p.erase(0, 4); + if (detail::startsWith(p, std::string("UNC\\"))) { + p.erase(0, 2); + p[0] = '\\'; + } + } + else if (detail::startsWith(p, std::string("\\??\\"))) { + p.erase(0, 4); } } for (auto& c : p) {