diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index 9540b44..69edaef 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -3365,10 +3365,14 @@ GHC_INLINE path::impl_string_type::const_iterator path::iterator::increment(cons } } else { +#ifdef GHC_OS_WINDOWS if (fromStart && i != _last && *i == ':') { ++i; } else { +#else + { +#endif i = std::find(i, _last, preferred_separator); } } diff --git a/test/filesystem_test.cpp b/test/filesystem_test.cpp index 23aeb95..cb08839 100644 --- a/test/filesystem_test.cpp +++ b/test/filesystem_test.cpp @@ -790,6 +790,9 @@ TEST_CASE("fs.path.decompose - path decomposition", "[filesystem][path][fs.path. CHECK(fs::path("C:/foo").filename() == "foo"); CHECK(fs::path("C:\\foo").filename() == "foo"); CHECK(fs::path("C:foo").filename() == "foo"); + CHECK(fs::path("t:est.txt").filename() == "est.txt"); +#else + CHECK(fs::path("t:est.txt").filename() == "t:est.txt"); #endif // stem() @@ -807,6 +810,11 @@ TEST_CASE("fs.path.decompose - path decomposition", "[filesystem][path][fs.path. CHECK(fs::path("/foo/.profile").stem() == ".profile"); CHECK(fs::path(".bar").stem() == ".bar"); CHECK(fs::path("..bar").stem() == "."); +#ifdef GHC_OS_WINDOWS + CHECK(fs::path("t:est.txt").stem() == "est"); +#else + CHECK(fs::path("t:est.txt").stem() == "t:est"); +#endif // extension() CHECK(fs::path("/foo/bar.txt").extension() == ".txt"); @@ -814,6 +822,7 @@ TEST_CASE("fs.path.decompose - path decomposition", "[filesystem][path][fs.path. CHECK(fs::path("/foo/.profile").extension() == ""); CHECK(fs::path(".bar").extension() == ""); CHECK(fs::path("..bar").extension() == ".bar"); + CHECK(fs::path("t:est.txt").extension() == ".txt"); if (has_host_root_name_support()) { // //host-based root-names