delete a file
#include <unistd.h>
int unlink( const char *path );
The unlink() function deletes the file whose name is the string
pointed to by path. This function is equivalent to the
remove() function.
The unlink() function returns zero if the operation succeeds,
nonzero if it fails, in which case errno is set.
- EACCES
- Search permission is denied for a component of path,
or write permission is denied on the directory containing the link to
be removed.
- EBUSY
- The directory named by the path
argument cannot be unlinked because it is being used by the system or
another process, and the implementation considers this to be an error.
- ENAMETOOLONG
- The argument path exceeds PATH_MAX in
length, or a pathname component is longer than NAME_MAX.
- ENOENT
- The named file doesn't exist, or path is an empty string.
- ENOTDIR
- A component of path isn't a directory.
- EPERM
- The file named by path
is a directory, and either the calling process doesn't have the
appropriate privileges, or the implementation prohibits using
unlink() on directories.
- EROFS
- The directory entry to be unlinked resides on a read-only file system.
#include <unistd.h>
void main()
{
unlink( "vm.tmp" );
}
POSIX 1003.1
Safety: | |
Interrupt handler |
No |
Signal handler |
Yes |
Thread |
Yes |
chdir(),
chmod(),
close(),
errno,
getcwd(),
link(),
mkdir(),
open(),
remove(),
rename(),
rmdir(),
stat()