
At 05:12 AM 9/9/2004, Martin wrote:
The filesystem status operations exists & is_directory will both throw if
the status of the file can't be determined (access problems or race conditions).
CVS for exists() was changed in March to always determine existence or no, and not to throw.
I think this makes the operations overly complicated to use since you need to enclose them in try catch blocks. You normally guard operations that use files in some way but it is easy to forget try/catch around exists / is_directory.
That isn't at all clear to me. I've rarely if ever seen people put try/catch around is_directory(). The thinking is that throws from is_directory all represent real errors, so should be caught higher up in the call tree along with all other general filesystem errors.
(Noticed that exists has been updated in CVS to return true on error
is probably ok but I think is_directory need to be updated as well.)
I think a good solution would be to have a non-throwing overload where
which the
return value in case of error is specified.
bool is_directory(const tdFS::path& aPath, bool aErrorRet) { try { return tdFS::is_directory(aPath); } catch (...) { return aErrorRet; } }
Another way could be to have a "is_accessable" operation that determines if the status of the entry can be determined but it will not solve the racing problem.
Yes, is_accessable() might be useful. But the use cases I can think of are a bit theoretical. Anyone else have an opinion? I think I'd like to hear about so real-life needs (rather than theoretical or hypothetical needs) before deciding. Thanks, --Beman