zkRemove - remove files
#include "zkStdio.h"
int zkRemove(const char* path);
The zkRemove() function causes the file named by the pathname pointed to by path to be no longer accessible by that name. A subsequent attempt to open that file using that name will fail, unless it is created anew.
Upon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error. If -1 is returned, the named file will not be removed.
The zkRemove() function will fail and not remove the file if:
- [EACCES]
- Search permission is denied for a component of the path prefix, or write permission is denied on the directory containing the directory entry to be removed, or write permission is denied on the parent directory of the directory to be removed.
- [EBUSY]
- The file or directory named by the path argument cannot be removed because it is being used by the system or another process and the implementation considers this an error.
- [EEXIST] or [ENOTEMPTY]
- The path argument names a directory that is not an empty directory.
- [EIO]
- A physical I/O error has occurred.
- [ELOOP]
- Too many symbolic links were encountered in resolving path.
- [ENAMETOOLONG]
- The length of the path argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}.
- [ENOENT]
- A component of path does not name an existing file, or the path argument names a non-existent directory or points to an empty string.
- [ENOTDIR]
- A component of the path prefix is not a directory.
- [EPERM]
- The file named by path is a directory, and either the calling process does not have appropriate privileges, or the implementation prohibits using zkRemove() on directories.
- [EPERM] or [EACCES]
- The S_ISVTX flag is set on the directory containing the file referred to by the path argument and the caller is not the file owner, nor is the caller the directory owner, nor does the caller have appropriate privileges. Or, the S_ISVTX flag is set on the parent directory of the directory to be removed and the caller is not the owner of the directory to be removed, nor is the caller the owner of the parent directory, nor does the caller have the appropriate privileges.
- [EROFS]
- The directory entry to be removed resides on a read-only file system.
The zkRemove() function may fail and not unlink the file if:
- [EBUSY]
- The file named by path is a named STREAM.
- [ENAMETOOLONG]
- Pathname resolution of a symbolic link produced an intermediate result whose length exceeds {PATH_MAX}.
- [ETXTBSY]
- The entry to be unlinked is the last directory entry to a pure procedure (shared text) file that is being executed.
The zkRemove() function may portably be used only to remove regular files. Any attempt to remove a directory, FIFO, STREAMS file, terminal device file, character special file, or block special file is non-portable.
The result of calling zkRemove() on an open file is implementation-defined.