[resend][filesystem] exists() throws exeption on existing but locked file on windows

Hi all, What's the rationale of throwing an exception from boost::filesystem::exists(somepath); when 'somepath' exists but is locked by some other process (at least on Windows)? A simple way to reproduce the effect is: #include <iostream> #include <boost/filesystem.hpp> int main() { boost::filesystem::path p("C:\\pagefile.sys"); try { boost::filesystem::exists(p); } catch (...) { std::cerr << "Ooops..." << std::endl; } return 0; } Throwing an exception doesn't seem to be the right thing here, since the file actually exists, so I'ld expect to get a 'true' back from exists(). Regards Hartmut

Hartmut Kaiser said: (by the date of Mon, 16 Apr 2007 07:23:50 -0500)
What's the rationale of throwing an exception from boost::filesystem::exists(somepath); when 'somepath' exists but is locked by some other process (at least on Windows)?
IMO it's a bug, you should submit it to bugtracker. -- Janek Kozicki |

What's the rationale of throwing an exception from boost::filesystem::exists(somepath); when 'somepath' exists but is locked by some other process (at least on Windows)? A simple way to reproduce the effect is:
The specific problem with exists is that windows just returns an error ("access denied"). Based on that you can't determine if the path actually exists. The problem might be that you don't have access to one of folders above. A more general problem with the filesystem library is that it is not expressed clearly enough that exceptions will happen in normal situations. When reading the docs you easily get the feeling that exceptions are something abnormal that can be handled in a toplevel catch. Situation has improved in the new version (in boost 1.34) where non-throwing operations are possible via the status() function. I still think the new code makes it more difficult than necessary to avoid exceptions but the author didn't agree.
participants (3)
-
Hartmut Kaiser
-
Janek Kozicki
-
Martin Adrian