*BSD News Article 67532


Return to BSD News archive

Newsgroups: comp.unix.misc,comp.unix.bsd.misc
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.uwa.edu.au!DIALix!metapro!bernie
From: bernie@metapro.DIALix.oz.au (Bernd Felsche)
Subject: Re: How to delete files within C programs
Message-ID: <DqtDDy.Hrq@metapro.DIALix.oz.au>
Organization: MetaPro Systems, Perth, Western Australia
References: <Oum-El-Kheir.Benkahla-3004961724540001@mac-ugm-3.imag.fr> <4m5p3k$3nq@dfw-ixnews2.ix.netcom.com> <4m7sr3$rf9@news.rhrz.uni-bonn.de>
Date: Fri, 3 May 1996 05:17:57 GMT
Lines: 28
Xref: euryale.cc.adfa.oz.au comp.unix.misc:22382 comp.unix.bsd.misc:897

In <4m7sr3$rf9@news.rhrz.uni-bonn.de>
  juengst@saph1.physik.uni-bonn.de (Henry G. Juengst) writes:

>In article <4m5p3k$3nq@dfw-ixnews2.ix.netcom.com>, SolutionWorks <solwork@popd.ix.netcom.com> writes:
>>Very simple solution, use the 'unlink' system function to delete files

>This might be a simple solution if you know the solution, but why should
>a beginner know that the function to delete a file is not something like
>'delete_file', but 'unlink' in the unix mud ? 

Nothing stops you from defining delete_file to be like unlink if you
prefer the larger amount of typing. unlink() won't actually delete the
file .. it removes one link from the inode and the corresponding
directory entry [ coincidentally, the space allocated to the inode is
released when the link count goes to zero ]. So delete_file is a
misnomer in that sense.

All of my *important* files have spare links in "hidden" directories
to catch stray "rm *" commands. ;-)

There is of course no single system call under conventional Unix which
deletes files... but that doesn't stop you from writing a function which
tries to do it.
-- 
Bernd Felsche {speaking for himself}
MetaPro Systems Pty Ltd, 130 Fauntleroy Avenue,
Redcliffe, Western Australia 6104
Phone: +61 9 479 3722    Fax: +61 9 479 3720