remove

Deletes a specified file or directory.

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

Syntax

  #include <stdio.h> 
   
  int remove (
     const char  *path);
  

Parameters

path

(IN) Points to the path of the file or directory to remove.

Return Values

If successful, returns 0; otherwise, return -1 and sets errno to one of the following:

Decimal

Constant

Description

1

ENOENT

The path parameter names a nonexistent directory or points to an empty string

6

EACCES

The caller does not have the appropriate privileges.

7

EEXIST

The path parameter specifies a directory that is not an empty directory.

9

EINVAL

The path parameter is invalid.

28

EIO

A physical I/O error has occurred.

62

EBUSY

The directory to be removed is currently in use by the system or some process.

65

ENAMETOOLONG

The length of the path parameter exceeds the maximum path length or the name of a path component is longer than the maximum name length.

67

ENOTDIR

A component of path is not a directory.

68

ENOTEMPTY

The path parameter specifies a directory that is not an empty directory.

69

EPERM

The caller does not have the appropriate privileges.

76

EROFS

The directory entry to be removed resides on a read-only file system.

Remarks

The remove function causes a file to be marked for deletion. A file marked for deletion is not actually erased until the space it occupies is needed by another file.

If the path parameter specifies a directory, the directory is removed only if it is an empty directory.

The current connection must have Delete rights to the specified file or directory.

Wildcard specifiers are allowed for the path parameter.

See Also

unlink