[Box Backup-dev] changeset [819]

Ben Summers boxbackup-dev at fluffy.co.uk
Fri Sep 1 09:07:04 BST 2006

On 1 Sep 2006, at 00:22, Chris Wilson wrote:

> Hi Martin,
> On Thu, 31 Aug 2006, Martin Ebourne wrote:
>> On Thu, 2006-08-31 at 20:51 +0100, Chris Wilson wrote:
>>> There is a possible clean solution, which is to use the Windows flag
>>> FILE_FLAG_DELETE_ON_CLOSE when opening the file. To avoid the  
>>> #ifdef, I
>>> think I would have to invent a new flag to pass to the FileStream
>>> constructor, which does nothing (define to zero) on other  
>>> platforms, but
>>> activates this Windows flag in openfile() on Win32.
>>> Does this seem like a sensible solution? And what should that  
>>> flag be
>>> called? O_DELETE_ON_CLOSE_WIN32?
>> How about FileStream handling this platform specific stuff. All  
>> you need
>> to do is tell FileStream when you construct it (use an overloaded
>> constructor or give an extra bool parameter to the constructor)  
>> that you
>> want the file automatically deleted.
> Seems like a good idea, much cleaner. Will implement tomorrow.

I would prefer a class derived from FileStream, with a descriptive  
name. Perhaps InvisibleTempFileStream or something? Then it's very  
clear what's going on.

>> On windows it would then pass FILE_FLAG_DELETE_ON_CLOSE and on  
>> unix it
>> would unlink it after opening it.
> FileStream calls ::openfile (from lib/win32/emu.cpp) to open the  
> file, so I would have to pass a new flag anyway, or a new  
> parameter, to make this happen. Alternatibely, FileStream could  
> delete the file itself in the Close method.

It's nicer to get the OS to do it for us.

>> Does that cover all possibilities? If so it would certainly tidy  
>> up a lot of code around the place that is closing and deleting files.
> I'm not certain that it covers them all, particularly renaming over  
> open files, but I'm sure it would help.

Which bits in the code do this? This tends to be done for atomic  
updates, but there's no reason why the replaced file  needs to be  
open. Maybe just calling Close() on the file before the rename would  
do and be OK for cross platform too?


More information about the Boxbackup-dev mailing list