Subject: Re: Switching from CVS to GIT

From: Eli Zaretskii <[email-masked]>
Date: Mon, 15 Oct 2007 06:12:55 +0200

> Date: Mon, 15 Oct 2007 02:22:53 +0100 (BST)
> From: Johannes Schindelin <[email-masked]>
> cc: Eli Zaretskii <[email-masked]>, Alex Riesen <[email-masked]>, [email-masked], 
>     [email-masked], [email-masked]
> 
> > You can achieve the same thing on Windows with CreateFile() by setting 
> > the dwShareMode parameter to zero and setting the 
> > FILE_FLAG_DELETE_ON_CLOSE attribute on dwFlagsAndAttributes.  This 
> > results in a file that cannot be opened or read by any other process and 
> > that will be automatically deleted when all open handles are closed.
> 
> Aha.  So to support Windows, we have to wrap all sites that use that 
> trick, and special case that #ifdef __MINGW32__. 

No, you need to think in abstractions rather than POSIX-isms, and then
let each platform implement those abstractions as appropriate.

> > > I think Alex means this: you can have C:\a\b\c and D:\a\b\c.  So 
> > > depending on which drive you are, you mean one or the other.  Just 
> > > comparing the paths is not enough.
> > 
> > This just means that you have to consider the drive letter as part of 
> > the filename.
> 
> So to support Windows, we have to special case having a ":" as second 
> character in the filename.

No, you need to think abstractions like `absolute_file_name' and
`dir_separator'.

> > > > > - no real "mmap" (which kills perfomance and complicates code)
> > > >
> > > > You only need mmap because you are accustomed to use it on GNU/Linux.
> > > 
> > > Yes.  And we rely on the performance very much.
> > 
> > Windows may not call it mmap() but it most certainly has memory-mapped
> > file IO:
> > <http://msdn2.microsoft.com/en-us/library/aa366781.aspx#file_mapping_functions>.
> 
> Yes, but there are still incompatibilities with POSIX.

Stop thinking POSIX.  Think abstractions that are common to POSIX and
non-POSIX systems.  If you think POSIX, don't be surprised that it
won't port.

> Again, when you did not close the file, you cannot delete (or
> rename) it.

Yes, you can, nowadays.  But that doesn't mean it was TRT to use such
dirty tricks to implement temporary files or security.  One needs to
think in abstractions again, and leave the implementation to each
platform.

> All this supporting Windows business is certainly possible, if tedious.

Only if the program was written with disregard to anything but POSIX.