[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to delete a file??



Pierre Phaneuf wrote:
> 
> Pierre Phaneuf wrote:
> 
> > > I don't think you should use 'remove' because it's not portable.
> >
> > According to remove(3):
> >
> > CONFORMING TO
> >        ANSI C, SVID, AT&T, POSIX, X/OPEN, BSD 4.3
> 
> And according to remove(3C) on Solaris 2.7:
> 
>      For files, remove() is identical to   unlink().  For  direc-
>      tories, remove() is identical to rmdir().
> 
> There is no "CONFORMING TO" sections in Solaris 2.7 man pages it seems
> (I checked a few other man pages for functions I knew were standard to
> make sure), so I cannot be sure of the conformance level on Solaris.

Well, irrespective of what the various standards say - 'remove' on
a libc4/5 Linux box won't delete a directory - so if you need the
functionality of a call that will blindly wipe out either a file
or a directory, you can't use 'remove' without dooming your program
to failure on about half the Linux boxes out there.

It's pretty irrelevent IMHO - I can't imagine many situations in
a program where you go blindly deleting a file without knowing
whether it's a directory or not!  Yikes!

If you know which you have then unlink and rmdir work fine
and are VERY portable.

-- 
Steve Baker                  http://web2.airmail.net/sjbaker1
sjbaker1@airmail.net (home)  http://www.woodsoup.org/~sbaker
sjbaker@hti.com      (work)