|
|
TC wrote:
> Darren, how do you delete an OS-locked file or directory under Windows XP?
You don't lock it. It's not that you can't delete an *open* file. You can't
delete an open file that was opened with the "don't let others write to this
while I have it open" flag. The program opening the file has to open it in
a way that lets you delete it, which is why I'm saying I'm surprised that
(for example) the usual C runtimes don't default to setting this flag, since
that's the default under UNIX.
The primary problem is that the call to run a program opens the file with
that lock, in part because it pages out of the file while it's running. The
file gets locked because to delete a file in Windows you actually have to
open the file for delete, which requires write privileges. Opening an
executing file for writing doesn't work under Windows *or* UNIX, but you
don't have to open the file under UNIX to delete it.
Alternately, you can stick stuff in the registry that'll delete the file (or
rename it) next time the machine is booted, before all the code that tends
to hold files open runs, if that's what you mean.
> Can you point me to an api-call?
It's just a normal delete.
> About the links: yes, windows does indeed support links. I do not dare to
> use them anymore. I tried once, but since people don't expect hard links
> under Windows to some it came as a nasty surprise when they discovered the
> doublettes they thought they were deleting were the actually hard linked
> files...
Well, yes. That's not a good reason for a programming environment not to use
them. It's just a good reason to be careful how you expose that to your
users. :-)
--
Darren New, San Diego CA, USA (PST)
Human nature dictates that toothpaste tubes spend
much longer being almost empty than almost full.
Post a reply to this message
|
|