Subject: [boost] Code review for bug no. 7396
From: ullas srinivas (ullas_n_s_at_[hidden])
Date: 2014-06-13 08:45:04
I have fixed bug no. 7396
Bug # 7396 :filesystem::path::remove_all(path,
error_code) throws filesystem_error exception
Description : Several methods in
filesystem::path, including remove_all, have an overload in which an extra
error_code& argument is taken. According to the docs, this is supposed to
cause failure (other than failure to allocate storage) to be reported in the
error_code rather than as a thrown filesystem_error exception. However,
remove_all can still throw filesystem_error exceptions because it uses a
directory_iterator internally but makes no attempt to catch exceptions thrown
by it. For example, if a subdirectory is deleted by another thread or process
just before remove_all tries to list its contents, directory_iterator_construct
will throw a filesystem_error that propagates up to remove_all's caller.
As a side note, I think path
and directory_iterator are both excessively exception-happy. It makes them
painful to use.
Root Cause : The exceptions thrown by fs::directory_iterator
were not handled in remove_all_aux function of operations.cpp file.
Fix: The exceptions thrown by fs::directory_iterator are
handled by catching the exception and proper ly assigning error values . Try-catch
statement has been put inside remove_all_aux function of operations.cpp file.
I kindly request you to please find the patch file attached and review the bug
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk