unlink

Deletes the specified file.

Library:LibC
Classification:POSIX
Service:File and Directory I/O

Syntax

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

Parameters

path

(IN) Points to a string containing the path of the file.

Return Values

If successful, returns 0. Otherwise, returns a -1 and sets errno to one of the following:

Decimal

Constant

Description

1

ENOENT

A component specified in the path does not exist or the path is an empty string.

6

EACCES

The caller has insufficient rights.

62

EBUSY

The specified file is in use.

65

ENAMETOOLONG

The length of the path argument exceeds the maximum path length, or a pathname component is longer than maximum name length.

67

ENOTDIR

A component specified in the path is not a directory.

69

EPERM

The caller has insufficient rights.

76

EROFS

The specified directory entry is part of a read-only file system.

Remarks

A file marked for deletion is not actually erased by unlink until the space it occupies is needed by another file.

The caller must have Delete rights to the file.

See Also

remove