Boost logo

Boost :

Subject: Re: [boost] [filesystem] copy_file() not atomic proposed fix
From: Beman Dawes (bdawes_at_[hidden])
Date: 2009-05-17 14:07:14


On Fri, May 15, 2009 at 5:10 AM, Andre Merzky <andre_at_...> wrote:
> Quoting [Beman Dawes] (May 12 2009):
>>
>> Ticket #2925 complains that "boost::filesystem cannot atomically copy
>> file if target exists" ...
>>
>> ...
>>
>> The proposed solution is to add an option to copy_file():
>>
>>     enum class copy_option { fail_if_exists, overwrite_if_exists };
>>
>>     void copy_file( const Path & from_path, const Path & to_path,
>>       copy_option option=copy_option::fail_if_exists );
>>
>> The implementation would be atomic on both POSIX and Windows.
>>
>> Comments?
>
> Makes sense.

OK, fix committed to trunk. It will go in branches/release once
sufficient regression tests have cycled.

> I would suggest to check the complete lib for similar
> problems.  I think most operational and convenience
> functions are prone to similar problems.

Hum... "most" is too strong; many of the operational functions are
implemented as a single operating system API call.

I really don't want to spend time analyzing and fixing the V2
codebase. Instead, I've added an item to the V3 do-list to do an
atomicity review. I'm planning to spend a lot of time on Filesystem.V3
this summer, and release a V3 beta as the code firms up.

Thanks,

--Beman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk