Opened 10 years ago

#7396 new Bugs

filesystem::path::remove_all(path, error_code) throws filesystem_error exception

Reported by: Craig Dickson <cdickson@…> Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.50.0 Severity: Problem
Keywords: Cc:

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.

Change History (0)

Note: See TracTickets for help on using tickets.