[darcs-users] DeleteFile on Windows

Simon Marlow marlowsd at gmail.com
Mon Oct 12 12:54:54 UTC 2009

On 10/10/2009 09:41, Salvatore Insalaco wrote:
> On Sat, Oct 10, 2009 at 10:26 AM, Petr Rockai<me at mornfall.net>  wrote:
>> That'd be great news. So basically, there are two bits we need to address:
>> - for _darcs/index, we need to first rename it to a suitable name and then delete
>> - we need to memory-map everything with FILE_SHARE_DELETE
>> The catch is, that we already do the latter and it doesn't really seem to help?
> I had a look at it, and actually (at least one) problem is a little
> bit different: there's too much share in mmap:
>      handle = CreateFileA(filepath,
>                           dwDesiredAccess,
>                           NULL,
>                           dwCreationDisposition,
>                           FILE_ATTRIBUTE_NORMAL,
>                           NULL);
> The issue is in Storage.Hashed.Index.indexFormatValid:
>    fd<- openBinaryFile path ReadMode
>    magic<- sequence [ hGetChar fd | _<- [1..size_magic] :: [Int] ]

slightly off-topic, but... ew.  At the very least:

    magic <- replicateM size_magic $ hGetChar fd

doesn't HLint say anything about that?

>    hClose fd
> openBinaryFile opens the file in a "posixy" way, and does not use
> FILE_SHARE_WRITE: its share request is then more strict than the one
> of the "first opener", and the open fails.
> I wrote a substitute of openBinaryFile that allows to specify share
> flags on Windows: I'm working on it :).

Sounds good.  Feel free to make the case (on libraries at haskell.org) that 
FILE_SHARE_DELETE should be the default.


More information about the darcs-users mailing list