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

Re: How to delete a file??








>I don't know how to delete a file in C without to use the fonction exec()
>with "rm".




NAME
     unlink - remove directory entry

SYNOPSIS
     #include <unistd.h>
     int unlink(const char *path);

DESCRIPTION
     The unlink() function removes a link to  a  file.   If  path
     names  a  symbolic  link, unlink() removes the symbolic link
     named by path and does not  affect  any  file  or  directory
     named  by  the  contents  of  the symbolic link.  Otherwise,
     unlink() removes the link named by the pathname  pointed  to
     by path and decrements the link count of the file referenced
     by the link.

     When the file's link count becomes 0 and no process has  the
     file  open, the space occupied by the file will be freed and
     the file will no longer  be  accessible.   If  one  or  more
     processes  have the file open when the last link is removed,
     the link will be removed before unlink()  returns,  but  the
     removal  of  the  file  contents will be postponed until all
     references to the file are closed.