Opened 10 years ago

Closed 6 years ago

#7307 closed Bugs (fixed)

boost::filesystem::remove_all(dirname,ec) throws on write protected directories

Reported by: bach@… Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.50.0 Severity: Problem
Keywords: Cc:

Description

Hi there,

according to the documentation, functions with error_code should not throw except if storage cannot be allocated.

The following throws if directory "bla" exists but is write protected:

  string bla("bla");
  boost::system::error_code ec;
  boost::filesystem::remove_all(bla,ec);

The bla directory looks like this:

ls -l bla
d--------- 2 bach bach     4096 2012-08-30 23:56 bla

Output of the program is:

terminate called after throwing an instance of "boost::filesystem::filesystem_error" what(): boost::filesystem::directory_iterator::construct: Permission denied: "bla" Aborted

System: Ubuntu 9.10 Boost: 1.50, looking through change notes for 1.51 I did not see any entries for filesystem which could address this.

Best,

Bastien

Change History (4)

comment:1 by viboes, 10 years ago

Component: Nonefilesystem
Owner: set to Beman Dawes

comment:3 by anonymous, 7 years ago

Any update on when this will be fixed ? I am new to this code so apologies if I misunderstood anything.

remove_all_aux() may have forgotten to pass the error_code argument to the constructor to the constructor of directory_iterator().

if (type == fs::directory_file) but not a directory symlink {

for (fs::directory_iterator itr(p); <<<---- itr(p, ec) instead ?!

itr != end_dir_itr; ++itr)

{

comment:4 by florian jacomme <florian@…>, 6 years ago

comment:5 by Beman Dawes, 6 years ago

Resolution: fixed
Status: newclosed

Hopefully fixed. Here is the commit message: Fix #7307, remove_all(dirname,ec) throws on write protected directories. This is a tough one to test. There are three internal function calls where errors might arise, and it would take too much time to write tests for each of those cases. Someday we will have Titus Winter's mock installable file system, but for now are relying on code inspection rather than testing.

Thanks for the bug report!

--Beman

Note: See TracTickets for help on using tickets.