Boost logo

Boost :

Subject: [boost] filesystem::remove_all error handling
From: Zachary Turner (divisortheory_at_[hidden])
Date: 2009-01-20 16:07:56


Has there been any discussion regarding the possibility of
filesystem::remove_all allowing a second parameter, a functor or function,
to be specified which on any file system error is called with the filename
that was attempted to be removed as well as the error code? My application,
for example, would like to log every single occurence of failure with a
warning, but still delete every possible file that it can, but I see no way
to handle this without rolling my own implementation of remove_all. Which
is fine if that's what I have to do, but at the same time it doesn't seem
that uncommon a case where someone would want to know about every single
error, yet still attempt every deletion possible. I guess one tricky aspect
of this is that you probably would not want to invoke the error callback if
the error code means "directory not empty" and the reason it is not empty is
because a file was unable to be deleted below the directory.

Side note, but the implementation of remove_all does not appear to be tail
recursive either, so even the best compiler will not be able to optimize
this into a loop, leading to the potential for a stack overflow in deeply
nested directory hierarchies. (Now that I think about it, I'm not even sure
what, if any, C++ compilers optimize tail recursive calls). Apologies if
either of these two issues has been addressed (I'm using 1.35.0), did not
find anything in the archives.

Thoughts?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk