[Box Backup-dev] changeset [819]

Martin Ebourne boxbackup-dev@fluffy.co.uk
Thu, 31 Aug 2006 23:59:27 +0100


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.

On windows it would then pass FILE_FLAG_DELETE_ON_CLOSE and on unix it
would unlink it after opening it.

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.

Cheers,

Martin.