From: | Mike Mascari <mascarm(at)mascari(dot)com> |
---|---|
To: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
Cc: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Win32 rename()/unlink() questions |
Date: | 2002-09-20 07:13:26 |
Message-ID: | 3D8ACA96.80504@mascari.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Justin Clift | 2002-09-20 08:04:05 | Would you be able to update the MySQL manual? |
Previous Message | Shridhar Daithankar | 2002-09-20 06:55:49 | Re: Where to post a new PostgreSQL utility? |