You can delete a file with the functions
Deletion actually deletes a file name. If this is the file's only name, then the file is deleted as well. If the file has other names as well (see section Hard Links), it remains accessible under its other names.
unlinkfunction deletes the file name filename. If this is a file's sole name, the file itself is also deleted. (Actually, if any process has the file open when this happens, deletion is postponed until all processes have closed the file.)
unlink is declared in the header file `unistd.h'.
This function returns
0 on successful completion, and
on error. In addition to the usual file name errors
(see section File Name Errors), the following
errno error conditions are
defined for this function:
unlinkcannot be used to delete the name of a directory, or can only be used this way by a privileged user. To avoid such problems, use
rmdirto delete directories. (In the GNU system
unlinkcan never delete the name of a directory.)
rmdirfunction deletes a directory. The directory must be empty before it can be removed; in other words, it can only contain entries for `.' and `..'.
In most other respects,
rmdir behaves like
are two additional
errno error conditions defined for
These two error codes are synonymous; some systems use one, and some use
the other. The GNU system always uses
The prototype for this function is declared in the header file `unistd.h'.
unlinkfor files and like
removeis declared in `stdio.h'.
Go to the first, previous, next, last section, table of contents.