unlink

delete a file

Synopsis:

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

Description:

The unlink() function deletes the file whose name is the string pointed to by path. This function is equivalent to the remove() function.

Returns:

The unlink() function returns zero if the operation succeeds, non-zero if it fails, in which case errno is set.

Errors:

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 does not exist, or path is an empty string.
ENOTDIR
A component of path is not a directory.
EPERM
The file named by path is a directory, and either the calling process does not 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.

See also:

chdir(), chmod(), close(), errno, getcwd(), link(), mkdir(), open(), remove(), rename(), rmdir(), stat()

Examples:

#include <unistd.h>

void main()
  {
    unlink( "vm.tmp" );
  }

Classification:

POSIX 1003.1

Systems:

All (except Netware, DOS/PM)