DELETE_ON_CLOSE on Win98/ME
Pierre A. Humblet
Pierre.Humblet@ieee.org
Tue Mar 18 01:18:00 GMT 2003
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
More information about the Cygwin-developers
mailing list