Modify

Opened 3 months ago

Last modified 3 months ago

#13217 new Bugs

remove_all(const path& p, system::error_code& ec) is not supposed to throw filesystem_error, but still can

Reported by: Brad Spencer <bspencer@…> Owned by:
Milestone: To Be Determined Component: None
Version: Boost 1.64.0 Severity: Problem
Keywords: Cc:

Description

I will be submitting a github pull request in association with this ticket.

According to the documentation, uintmax_t remove_all(const path& p, system::error_code& ec) is not supposed to throw filesystem_error. However, when the directory_iterator used in the loop inside the implementation helper function remove_all_aux() is incremented, it's not done in a way that considers the ec argument. So, when incrementing the iterator fails, the operator++() on the directory_iterator throws, which leads to remove_all() incorrectly throwing.

To fix this, it seems that one can take the same approach as the recent changes for Fix #7307 (commit 4e4374336c640c2717f6a1b168406e11bdf7d6f1) and replace the ++itr call in the loop with an explicit call to either directory_iterator::increment(system::error_code& ec) whenever an ec argument is in effect. This should prevent remove_all() from throwing in such cases and thus allow it to conform to its interface specification.

BTW I also found these possibly related tickets in Trac:

Attachments (0)

Change History (1)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.