filesystem::remove_all error handling

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?

AMDG Zachary Turner wrote:
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).
If a function has any local variables with non-trivial destructors, it cannot be tail-recursive. Tail recursion is not worth worrying about in C++. In Christ, Steven Watanabe
participants (2)
-
Steven Watanabe
-
Zachary Turner