Boost logo

Boost :

From: dizzy (dizzy_at_[hidden])
Date: 2008-05-30 08:02:17

On Friday 30 May 2008 12:52:29 you wrote:
> Is this a bug? If so, I should put it in the tracker?

In the mean time as one of my coleagues has found that remove_all is also
affected by the issue (once because it also does a broken bfs::exists() check
first and second because remove_all_aux() calls bfs::remove() to remove
elements) and I noticed that remove and especially remove_all implementations
are not written with efficency in mind, ie remove_all cals indirectly
lstat/fstat about 4 times per each element that will be deleted:
- one "lstat" from is_symlink
- a "fstat" from is_directory
- a "fstat" from remove() bfs::exists call
- in case the file is a directory another "fstat" from directory_iterator ctor
- in case the removed file is a dangling symlink another "lstat" from
is_symlink from remove()) instead of doing it once and reusing the returned

I have reworked remove and remove_all functions in boost 1.35.0 (I also have a
patch for 1.34.1 for who is interested since we have some software still
using it) to not have the reported bug and be more efficient "lstat/fstat"

Patch attached.

PS: the resulting code still has one redundant "stat" because of
directory_iterator ctor, if one wants to eliminate that too just have a
directory_iterator ctor version that takes a file_status argument instead of
invoking itself (indirectly) "stat" to query that information

Mihai RUSU					Email: dizzy_at_[hidden]
			"Linux is obsolete" -- AST

Boost list run by bdawes at, gregod at, cpdaniel at, john at