In the C++17 filesystem library, we got std::filesystem::remove(path)
, which — as I understand it — is a direct port of boost::filesystem::remove(path)
from Boost.Filesystem.
But C++ inherited from C89 a very similar function called std::remove(path)
, which is also documented as a way to remove a file from the filesystem. I'm vaguely aware of some pitfalls with this function, e.g. I believe I have heard that on Windows std::remove
cannot be used to remove a file that is still being held open by the current process.
Does std::filesystem::remove
fix these issues with std::remove
? Should I prefer std::filesystem::remove
over std::remove
? Or is the former just a namespaced synonym for the latter, with the same warts and pitfalls?
The title of my question asks for the difference between boost::filesystem::remove(path)
and std::remove(path)
because I figure that std::filesystem::remove(path)
may not have been implemented by a lot of library vendors yet, but my understanding is that it's supposed to be basically a direct copy of the Boost version. So if you know about Boost.Filesystem on Windows, you probably know enough to answer this question too.