File tree Expand file tree Collapse file tree
src/unicode/utf8_everywhere
test/unicode/utf8_everywhere Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -140,9 +140,14 @@ std::filesystem::path extended_path(const std::filesystem::path& path) NOEXCEPT
140140 // However this includes "considered relative" paths (with ".." segments).
141141 // That is of no consequence here because those will also be converted.
142142 // MAX_PATH includes the terminator, so a path of that length requires it.
143+ // An already extended path (e.g. by a shell) is not extended again.
143144 BC_PUSH_WARNING (NO_THROW_IN_NOEXCEPT )
145+ constexpr std::wstring_view prefix{ L" \\\\ ?\\ " };
144146 const auto full = qualified_path (path).wstring ();
145- return { (full.length () >= MAX_PATH ) ? L" \\\\ ?\\ " + full : full };
147+ if (full.starts_with (prefix) || full.length () < MAX_PATH )
148+ return { full };
149+
150+ return { std::wstring{ prefix } + full };
146151 BC_POP_WARNING ()
147152}
148153
Original file line number Diff line number Diff line change @@ -193,6 +193,12 @@ BOOST_AUTO_TEST_CASE(paths__extended_path__maximum__extended)
193193 BOOST_REQUIRE_EQUAL (extended_path ({ test_maximum }), test_maximum_extended);
194194}
195195
196+ BOOST_AUTO_TEST_CASE (paths__extended_path__extended__unchanged)
197+ {
198+ BOOST_REQUIRE_EQUAL (extended_path (test_extended), test_extended);
199+ BOOST_REQUIRE_EQUAL (extended_path (test_maximum_extended), test_maximum_extended);
200+ }
201+
196202BOOST_AUTO_TEST_SUITE_END ()
197203
198204BC_POP_WARNING ()
You can’t perform that action at this time.
0 commit comments