gulrak / filesystem

An implementation of C++17 std::filesystem for C++11 /C++14/C++17/C++20 on Windows, macOS, Linux and FreeBSD.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

On Windows, when the find directory is finished, the handle is not closed.

actboy168 opened this issue · comments

Describe the bug
I'm not sure if this meets the C++ standard, but both msvc and mingw implementations do this.

To Reproduce

auto path = fs::path("test/");
fs::create_directory(path);
auto itor = fs::directory_iterator(path);
while (itor != fs::directory_iterator()) {
    ++itor;
}
fs::remove_all(path);
fs::create_directory(path); // throw an exception

When itor is equal to end(), it releases the resources held by itor. fs::create_directory will not throw an exception.

Expected behavior
The second fs::create_directory works fine.

Additional context

Yeah, the standard doesn't specify detailed enough, but that code works on C++17 std::filesystem of GCC8 on macOS and Linux and my own POSIX implementation, so I agree, it should work.

Closed with release of v1.0.8