Name
unlink - delete a name and possibly the file it refers to
Library
libc.lib
Synopsis
|
int
unlink (const char *path);
|
Return values
Upon successful completion, 0 shall be returned.
Otherwise, -1 shall be returned and
errno
set to indicate the error.
Detailed description
The
unlink
system call
removes the link named by
path
from its file system. It is expected to decrement the link count of the
file which was referenced by the link, but since this is a simulated function
and not supported by the platform, link count does not get modified.
As the parent file to which a link is created itself is unaware about the link,
a unlink on the parent file will close the file regardless of weather there existed any
link to the file.
The
path
argument
may not be a directory.
Examples
/*
* Detailed description : Example to unlink a link file
* Precondition : A link file by name "Link" should exist in
* c: drive.
*/
#include <unistd.h>
#include <stdio.h>
int main(void)
{
char rdbuff[25];
if(unlink("C:\ink"))
{
printf("unlink on link file failed");
}
printf("Unlink on link file succeeded");
}
Output
Unlink on link file succeeded.
Errors
The
unlink
succeeds unless:
[ENOENT]
|
|
The named file does not exist.
|
[EINVAL]
|
|
A relative path was encountered in translating
path
and is not supported by the platform.
|
[ENOENT]
|
|
An empty path was encountered while translating the pathname.
|
[EACCESS]
|
|
The file named by the path argument cannot be unlinked because
it is being used by the system or another process and the implementation considers this an error.
|
See also
close,
link,
rmdir,
symlink
Feedback
For additional information or queries on this page send feedback
© 2005-2007 Nokia
|
|