Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into glibcxx_wchar_strea…
Browse files Browse the repository at this point in the history
…ms_workaround
  • Loading branch information
rikyoz committed Apr 14, 2024
2 parents c0dcd0b + 42ea4fc commit 983650f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,10 @@ The `CMakeLists.txt` offers a few options to customize its behavior:
`CMAKE_CXX_COMPILE_FEATURES` when the detection of C++17 or C++20 for additional tests
is not working (e.g. `cxx_std_20` to enforce building a `filesystem_test_cpp20` with C++20).

### Bazel

Please use [hedronvision/bazel-cc-filesystem-backport](https://github.com/hedronvision/bazel-cc-filesystem-backport), which will automatically set everything up for you.

### Versioning

There is a version macro `GHC_FILESYSTEM_VERSION` defined in case future changes
Expand Down
9 changes: 6 additions & 3 deletions include/ghc/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3431,6 +3431,9 @@ GHC_INLINE path path::lexically_relative(const path& base) const
--count;
}
}
if (count == 0 && (a == end() || a->empty())) {
return path(".");
}
if (count < 0) {
return path();
}
Expand Down Expand Up @@ -4099,7 +4102,7 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options
}
ssize_t br, bw;
while (true) {
do { br = ::read(in, buffer.data(), buffer.size()); } while(errno == EINTR);
do { br = ::read(in, buffer.data(), buffer.size()); } while(errno == EINTR && !br);
if(!br) {
break;
}
Expand Down Expand Up @@ -5818,7 +5821,7 @@ class directory_iterator::impl
, _entry(nullptr)
{
if (!path.empty()) {
do { _dir = ::opendir(path.native().c_str()); } while(errno == EINTR);
do { _dir = ::opendir(path.native().c_str()); } while(errno == EINTR && !_dir);
if (!_dir) {
auto error = errno;
_base = filesystem::path();
Expand All @@ -5845,7 +5848,7 @@ class directory_iterator::impl
do {
skip = false;
errno = 0;
do { _entry = ::readdir(_dir); } while(errno == EINTR);
do { _entry = ::readdir(_dir); } while(errno == EINTR && !_entry);
if (_entry) {
_dir_entry._path = _base;
_dir_entry._path.append_name(_entry->d_name);
Expand Down
4 changes: 4 additions & 0 deletions test/filesystem_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,10 @@ TEST_CASE("fs.path.gen - path generation", "[filesystem][path][fs.path.gen]")
// lexically_relative()
CHECK(fs::path("/a/d").lexically_relative("/a/b/c") == "../../d");
CHECK(fs::path("/a/b/c").lexically_relative("/a/d") == "../b/c");
CHECK(fs::path("/a/b/c").lexically_relative("/a/b/c/d/..") == ".");
CHECK(fs::path("/a/b/c/").lexically_relative("/a/b/c/d/..") == ".");
CHECK(fs::path("").lexically_relative("/a/..") == "");
CHECK(fs::path("").lexically_relative("a/..") == ".");
CHECK(fs::path("a/b/c").lexically_relative("a") == "b/c");
CHECK(fs::path("a/b/c").lexically_relative("a/b/c/x/y") == "../..");
CHECK(fs::path("a/b/c").lexically_relative("a/b/c") == ".");
Expand Down

0 comments on commit 983650f

Please sign in to comment.