delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/2003/03/17/20:18:25

Mailing-List: contact cygwin-developers-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-developers-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT cygwin DOT com>
List-Help: <mailto:cygwin-developers-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-developers-owner AT cygwin DOT com
Delivered-To: mailing list cygwin-developers AT cygwin DOT com
Message-Id: <3.0.5.32.20030317201728.007f3d10@incoming.verizon.net>
X-Sender: vze1u1tg AT incoming DOT verizon DOT net
Date: Mon, 17 Mar 2003 20:17:28 -0500
To: <cygwin-developers AT cygwin DOT com>
From: "Pierre A. Humblet" <Pierre DOT Humblet AT ieee DOT org>
Subject: DELETE_ON_CLOSE on Win98/ME
In-Reply-To: <LPEHIHGCJOAIPFLADJAHCEAADHAA.chris@atomice.net>
References: <20030317145931 DOT GA30463 AT redhat DOT com>
Mime-Version: 1.0

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

 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019