Name
readlink - read value of a symbolic link
Library
libc.lib
Synopsis
|
int
readlink (const char *path, char *buf, int bufsiz);
|
Return values
The call returns the count of characters placed in the buffer
if it succeeds, or a -1 if an error occurs, placing the error
code in the global variable
errno.
Detailed description
The
readlink
system call
places the contents of the symbolic link
path
in the buffer
buf,
which has size
bufsiz.
The
readlink
system call does not append a
NUL
character to
buf.
Examples
/*
* Detailed description: Example to read a link file
* Precondition: "Parent.txt" should exist in c: drive with some contents
* of length atleast 25 characters. And a link file by name
* "C:\Link" pointing to parent file should exist.
*
*/
#include <unistd.h>
#include <stdio.h>
int main(void)
{
char rdbuff[25];
int retval;
if((retval = (readlink("C:\ink", rdbuff, (sizeof(char)*25)))) < 0)
{
printf("Read through link file failed");
perror(" ");
return -1;
}
printf("Read through link file succeeded");
}
Output
Read through link file succeeded.
Errors
The
readlink
system call
will fail if:
[ENOENT]
|
|
The named file does not exist.
|
[ENAMETOOLONG]
|
|
A component or an entire path name exceeded 255 characters.
|
[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.
|
See also
lstat,
stat,
symlink,
symlink
Feedback
For additional information or queries on this page send feedback
© 2005-2007 Nokia
|
|