mirror of
https://git.mirrors.martin98.com/https://github.com/gulrak/filesystem
synced 2025-06-04 11:13:58 +08:00
Merge branch 'feature-122-recursive-iterator-follows-dead-symlinks'
# Conflicts: # README.md
This commit is contained in:
commit
231b64fec0
@ -5843,8 +5843,11 @@ GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::operator+
|
||||
|
||||
GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::increment(std::error_code& ec) noexcept
|
||||
{
|
||||
bool isDir = (*this)->is_directory(ec);
|
||||
bool isSymLink = !ec && (*this)->is_symlink(ec);
|
||||
bool isSymLink = (*this)->is_symlink(ec);
|
||||
bool isDir = !ec && (*this)->is_directory(ec);
|
||||
if(isSymLink && detail::is_not_found_error(ec)) {
|
||||
ec.clear();
|
||||
}
|
||||
if(!ec) {
|
||||
if (recursion_pending() && isDir && (!isSymLink || (options() & directory_options::follow_directory_symlink) != directory_options::none)) {
|
||||
_impl->_dir_iter_stack.push(directory_iterator((*this)->path(), _impl->_options, ec));
|
||||
|
@ -1596,6 +1596,37 @@ TEST_CASE("fs.class.rec.dir.itr - class recursive_directory_iterator", "[filesys
|
||||
}
|
||||
CHECK(os.str() == "[./a,0],[./d1,0],[./d1/d2,1],[./e,0],");
|
||||
}
|
||||
if (is_symlink_creation_supported()) {
|
||||
TemporaryDirectory t(TempOpt::change_path);
|
||||
fs::create_directory("d1");
|
||||
generateFile("d1/a");
|
||||
fs::create_directory("d2");
|
||||
generateFile("d2/b");
|
||||
fs::create_directory_symlink("../d1", "d2/ds1");
|
||||
fs::create_directory_symlink("d3", "d2/ds2");
|
||||
std::multiset<std::string> result;
|
||||
REQUIRE_NOTHROW([&](){
|
||||
for (const auto& de : fs::recursive_directory_iterator("d2", fs::directory_options::follow_directory_symlink)) {
|
||||
result.insert(de.path().generic_string());
|
||||
}
|
||||
}());
|
||||
std::stringstream os;
|
||||
for(const auto& p : result) {
|
||||
os << p << ",";
|
||||
}
|
||||
CHECK(os.str() == "d2/b,d2/ds1,d2/ds1/a,d2/ds2,");
|
||||
os.str("");
|
||||
result.clear();
|
||||
REQUIRE_NOTHROW([&](){
|
||||
for (const auto& de : fs::recursive_directory_iterator("d2")) {
|
||||
result.insert(de.path().generic_string());
|
||||
}
|
||||
}());
|
||||
for(const auto& p : result) {
|
||||
os << p << ",";
|
||||
}
|
||||
CHECK(os.str() == "d2/b,d2/ds1,d2/ds2,");
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("fs.op.absolute - absolute", "[filesystem][operations][fs.op.absolute]")
|
||||
|
Loading…
x
Reference in New Issue
Block a user