This is the mail archive of the
cygwin-developers@cygwin.com
mailing list for the Cygwin project.
DELETE_ON_CLOSE on Win98/ME
- From: "Pierre A. Humblet" <Pierre dot Humblet at ieee dot org>
- To: <cygwin-developers at cygwin dot com>
- Date: Mon, 17 Mar 2003 20:17:28 -0500
- Subject: DELETE_ON_CLOSE on Win98/ME
- References: <20030317145931.GA30463@redhat.com>
Chris,
here is what I observe on Win98/ME. There is never any problem
if the file is not read-only. If it is, the sequence
CreateFile( FILE_FLAG_DELETE_ON_CLOSE )
SetFileAttributes (read_only)
CloseHandle ()
has the following result:
1) File on local disk: not deleted
2) File on shared drive, mounted on 98/ME: deleted
3) File on shared drive, mounted on NT class: not deleted
So in the case of read-only hard link, I see no way to avoid
leaving the surviving copy as read-write.
The CloseHandle always returns OK. So, short of checking for
deletion each time, I see two ways of handling the situation
A)
CreateFile( FILE_FLAG_DELETE_ON_CLOSE )
if (wincap.has_hard_links ())
SetFileAttributes ( read_only)
CloseHandle ()
B) (simpler/faster, same overall result)
if (wincap.has_delete_on_close ())
{
CreateFile( FILE_FLAG_DELETE_ON_CLOSE )
SetFileAttributes ( read_only)
CloseHandle ()
}
Pierre