Re: Win32 rename()/unlink() questions

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Mike Mascari <mascarm(at)mascari(dot)com>
Cc: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Win32 rename()/unlink() questions
Date: 2002-09-20 14:31:22
Message-ID: 200209201431.g8KEVMg13344@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


I don't think we are not going to be supporting Win9X so there isn't an
issue there. We will be supporting Win2000/NT/XP.

I don't understand FILE_SHARE_DELETE. I read the description at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/createfile.asp

but I don't understand it:

FILE_SHARE_DELETE - Windows NT/2000/XP: Subsequent open operations on
the object will succeed only if delete access is requested.

---------------------------------------------------------------------------

Mike Mascari wrote:
> Stephan Szabo wrote:
> > On Fri, 20 Sep 2002, Mike Mascari wrote:
> >>
> >>Yes! Indeed that does work.
> >
> >
> > Thinking back, I think that may still fail on Win95 (using MoveFile).
> > Once in the past I had to work on (un)installers for Win* and I
> > vaguely remember Win95 being more strict than Win98 but that may just
> > have been with moving the executable you're currently running.
>
> Well, here's the test:
>
> foo.txt contains "This is FOO!"
> bar.txt contains "This is BAR!"
>
> Process 1 opens foo.txt
> Process 2 opens foo.txt
> Process 1 sleeps 7.5 seconds
> Process 2 sleeps 15 seconds
> Process 1 uses MoveFile() to rename "foo.txt" to "foo2.txt"
> Process 1 uses MoveFile() to rename "bar.txt" to "foo.txt"
> Process 1 uses DeleteFile() to remove "foo2.txt"
> Process 2 awakens and displays "This is FOO!"
>
> On the filesystem, we then have:
>
> foo.txt containing "This is BAR!"
>
> The good news is that this works fine under NT 4 using just
> MoveFile(). The bad news is that it requires the files be opened
> using CreateFile() with the FILE_SHARE_DELETE flag set. The C
> library which ships with Visual C++ 6 ultimately calls
> CreateFile() via fopen() but with no opportunity through the
> standard C library routines to use the FILE_SHARE_DELETE flag.
> And the FILE_SHARE_DELETE flag cannot be used under Windows
> 95/98 (Bad Parameter). Which means, on those platforms, there
> still doesn't appear to be a solution. Under NT/XP/2K,
> AllocateFile() will have to modified to call CreateFile()
> instead of fopen(). I'm not sure about ME, but I suspect it
> behaves similarly to 95/98.
>
> Mike Mascari
> mascarm(at)mascari(dot)com
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephan Szabo 2002-09-20 14:38:25 Re: timestamp parse error
Previous Message Tom Lane 2002-09-20 14:27:52 Re: Win32 rename()/unlink() questions