Skip to content

Commit b6d302f

Browse files
committed
Merge branch 'feature-156-posix-issue-stem-filename-extension'
2 parents bc05cc5 + efc077f commit b6d302f

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

include/ghc/filesystem.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3369,10 +3369,14 @@ GHC_INLINE path::impl_string_type::const_iterator path::iterator::increment(cons
33693369
}
33703370
}
33713371
else {
3372+
#ifdef GHC_OS_WINDOWS
33723373
if (fromStart && i != _last && *i == ':') {
33733374
++i;
33743375
}
33753376
else {
3377+
#else
3378+
{
3379+
#endif
33763380
i = std::find(i, _last, preferred_separator);
33773381
}
33783382
}

test/filesystem_test.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,9 @@ TEST_CASE("fs.path.decompose - path decomposition", "[filesystem][path][fs.path.
790790
CHECK(fs::path("C:/foo").filename() == "foo");
791791
CHECK(fs::path("C:\\foo").filename() == "foo");
792792
CHECK(fs::path("C:foo").filename() == "foo");
793+
CHECK(fs::path("t:est.txt").filename() == "est.txt");
794+
#else
795+
CHECK(fs::path("t:est.txt").filename() == "t:est.txt");
793796
#endif
794797

795798
// stem()
@@ -807,13 +810,19 @@ TEST_CASE("fs.path.decompose - path decomposition", "[filesystem][path][fs.path.
807810
CHECK(fs::path("/foo/.profile").stem() == ".profile");
808811
CHECK(fs::path(".bar").stem() == ".bar");
809812
CHECK(fs::path("..bar").stem() == ".");
813+
#ifdef GHC_OS_WINDOWS
814+
CHECK(fs::path("t:est.txt").stem() == "est");
815+
#else
816+
CHECK(fs::path("t:est.txt").stem() == "t:est");
817+
#endif
810818

811819
// extension()
812820
CHECK(fs::path("/foo/bar.txt").extension() == ".txt");
813821
CHECK(fs::path("/foo/bar").extension() == "");
814822
CHECK(fs::path("/foo/.profile").extension() == "");
815823
CHECK(fs::path(".bar").extension() == "");
816824
CHECK(fs::path("..bar").extension() == ".bar");
825+
CHECK(fs::path("t:est.txt").extension() == ".txt");
817826

818827
if (has_host_root_name_support()) {
819828
// //host-based root-names

0 commit comments

Comments
 (0)