From: Carl Hetherington Date: Tue, 11 May 2021 14:09:20 +0000 (+0200) Subject: Don't apply the Windows long path fix twice. X-Git-Tag: v2.15.147 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=980336455724bbdb73f3fb3d521e36c71f9345e5 Don't apply the Windows long path fix twice. --- diff --git a/src/lib/cross_windows.cc b/src/lib/cross_windows.cc index d97550ca9..ac92aa7eb 100644 --- a/src/lib/cross_windows.cc +++ b/src/lib/cross_windows.cc @@ -252,7 +252,12 @@ boost::filesystem::path fix_long_path (boost::filesystem::path long_path) { using namespace boost::filesystem; + path fixed = "\\\\?\\"; + if (boost::algorithm::starts_with(long_path.string(), fixed.string())) { + return long_path; + } + /* We have to make the path canonical but we can't call canonical() on the long path * as it will fail. So we'll sort of do it ourselves (possibly badly). */ diff --git a/test/windows_test.cc b/test/windows_test.cc index 4d07d5fdf..bc9520bc3 100644 --- a/test/windows_test.cc +++ b/test/windows_test.cc @@ -35,6 +35,8 @@ BOOST_AUTO_TEST_CASE (fix_long_path_test) fixed_bar += boost::filesystem::current_path(); fixed_bar /= "bar"; BOOST_CHECK_EQUAL (fix_long_path("bar"), fixed_bar); + + BOOST_CHECK_EQUAL (fix_long_path("\\\\?\\c:\\foo"), "\\\\?\\c:\\foo"); #else BOOST_CHECK_EQUAL (fix_long_path("foo/bar/baz"), "foo/bar/baz"); #endif