From c31946041a5da1724b985944b98cee9daebec340 Mon Sep 17 00:00:00 2001 From: DDoSolitary Date: Fri, 26 Jun 2020 12:43:26 +0800 Subject: [PATCH] Support paths with "\\?\" prefix. Fix #127. --- .idea/codeStyles/codeStyleConfig.xml | 5 +++++ src/path.cpp | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .idea/codeStyles/codeStyleConfig.xml diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..df5f35d --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/src/path.cpp b/src/path.cpp index 2035949..d0f4217 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -128,7 +128,12 @@ std::unique_ptr linux_path::clone() const { wsl_path::wsl_path(crwstr base) : file_path(normalize_path(base)) {} wstr wsl_path::normalize_path(crwstr path) { - auto o = L"\\\\?\\" + get_full_path(path); + const auto prefix = L"\\\\?\\"; + const auto prefix_len = wcslen(prefix); + auto o = get_full_path(path); + if (o.compare(0, prefix_len, prefix) != 0) { + o = L"\\\\?\\" + get_full_path(path); + } if (o.back() != L'\\') o += L'\\'; return o; }