Stephan Szabo wrote:
> On Fri, 20 Sep 2002, Mike Mascari wrote:
>>I think that's a rather poor description. I think it just means
>>that if the file is opened once via CreateFile() with
>>FILE_SHARE_DELETE, then any subsequent CreateFile() calls will
>>fail unless they too have FILE_SHARE_DELETE. In other words, if
>>one of us can delete this file while its open, any of us can.
> The question is, what happens if two people have the file open
> and one goes and tries to delete it?  Can the other still read
> from it?

Yes. I just tested it and it worked. I'll test Bruce's scenario 
as well:

foo contains: "FOO"
bar contains: "BAR"

1. Process 1 opens "foo"
2. Process 2 opens "foo"
3. Process 1 calls MoveFile("foo", "foo2");
4. Process 3 opens "foo" <- Successful?
5. Process 1 calls MoveFile("bar", "foo");
6. Process 4 opens "foo" <- Successful?
7. Process 1 calls DeleteFile("foo2");
8. Process 1, 2, 3, 4 all read from their respective handles.

I think the thing to worry about is a race condition between the 
two MoveFile() attempts. A very ugly hack would be to loop in a 
CreateFile() in an attempt to open "foo", giving up if the error 
is not a NOT EXISTS error code.

Mike Mascari

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to