[darcs-users] DeleteFile on Windows
me at mornfall.net
Wed Oct 28 07:38:39 UTC 2009
Salvatore Insalaco <kirby81 at gmail.com> writes:
> On Tue, Oct 27, 2009 at 10:12 AM, Petr Rockai <me at mornfall.net> wrote:
>> Petr Rockai <me at mornfall.net> writes:
>> From my reading of MSDN, it seems that you can never use DeleteFile on open
>> files. However, you can create a new handle using FILE_FLAG_DELETE_ON_CLOSE.
> This is not really true: you can delete an open file but you cannot
> create another file with the same name or delete the parent directory
> until all the handles have been closed (FILE_SHARE_DELETE + DeleteFile
> behavior is very similar to DELETE_ON_CLOSE).
> The problem is that unfortunately this doesn't work with mmapped files.
I have experimented a little more yesterday, and DELETE_ON_CLOSE seems to work
well even with mmapped files. It does not work on network drives though (at
least not on virtualbox-exported network drives), which may or may not be a
problem. (The problem triggers when accessing the contents after closing the
DELETE_ON_CLOSE handle -- I think darcs doesn't do this though.)
>> If the file was open with FILE_SHARE_DELETE previously, this should roughly
>> work. I haven't tested since it's difficult to work on win32 for me. Salvatore,
>> do you think this is something you could find time to do at the sprint in
> I thought about doing it before Vienna, but unfortunately it seems
> harder than I initially thought: there are some cases where we try to
> delete the parent directory of a opened mmapped file.
Hmm, that's unfortunate. Renaming the file out of the directory would probably
still work, but yes, it complicates things quite a bit. (Sigh, Windows.)
> I already did some work that cut the failing tests on Windows by half,
> but there's more work to do!
> A 100% working Darcs 2.4 on Windows will probably be my Vienna task :).
More information about the darcs-users