Don't apply the Windows long path fix twice. v2.15.147
authorCarl Hetherington <cth@carlh.net>
Tue, 11 May 2021 14:09:20 +0000 (16:09 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 11 May 2021 14:09:20 +0000 (16:09 +0200)
src/lib/cross_windows.cc
test/windows_test.cc

index d97550ca9730aae138516619dc2d9173ff31acf3..ac92aa7eb730b8364673b8b8725b862453b7975f 100644 (file)
@@ -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).
         */
index 4d07d5fdfd9335722360a8089ec54a462d3d7217..bc9520bc33abc2d5edd013b257e1cacc420a4441 100644 (file)
@@ -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