mirror of
https://git.mirrors.martin98.com/https://github.com/gulrak/filesystem
synced 2025-06-04 11:13:58 +08:00
Merge branch 'feature-70-path-comparison' of https://github.com/gulrak/filesystem into feature-70-path-comparison
# Conflicts: # include/ghc/filesystem.hpp
This commit is contained in:
commit
2fe72421c5
@ -2695,8 +2695,8 @@ GHC_INLINE int path::compare(const path& p) const noexcept
|
||||
++rnl1;
|
||||
++rnl2;
|
||||
}
|
||||
auto iter1 = _path.begin() + rnl1;
|
||||
auto iter2 = p._path.begin() + rnl2;
|
||||
auto iter1 = _path.begin() + static_cast<int>(rnl1);
|
||||
auto iter2 = p._path.begin() + static_cast<int>(rnl2);
|
||||
while (iter1 != _path.end() && iter2 != p._path.end() && *iter1 == *iter2) {
|
||||
++iter1;
|
||||
++iter2;
|
||||
@ -2723,9 +2723,9 @@ GHC_INLINE int path::compare(const path& p) const noexcept
|
||||
return rnc;
|
||||
}
|
||||
auto p1 = _path;
|
||||
std::replace(p1.begin()+rnl1, p1.end(), '/', '\\');
|
||||
std::replace(p1.begin()+static_cast<int>(rnl1), p1.end(), '/', '\\');
|
||||
auto p2 = p._path;
|
||||
std::replace(p2.begin()+rnl2, p2.end(), '/', '\\');
|
||||
std::replace(p2.begin()+static_cast<int>(rnl2), p2.end(), '/', '\\');
|
||||
return p1.compare(rnl1, std::string::npos, p2, rnl2, std::string::npos);
|
||||
#else
|
||||
return _path.compare(p._path);
|
||||
|
@ -618,6 +618,7 @@ TEST_CASE("30.10.8.4.8 path compare", "[filesystem][path][fs.path.compare]")
|
||||
|
||||
#ifdef GHC_OS_WINDOWS
|
||||
CHECK(fs::path("c:\\a\\b").compare("C:\\a\\b") == 0);
|
||||
CHECK(fs::path("c:\\a\\b").compare("d:\\a\\b") != 0);
|
||||
CHECK(fs::path("c:\\a\\b").compare("C:\\A\\b") != 0);
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user