delorie.com/djgpp/doc/libc/libc_491.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

__internal_readlink

Syntax

 
#include <libc/symlink.h>

int __internal_readlink(const char * path, int fhandle,
                        char * buf, size_t max)

Description

In general applications shouldn't call this function; use readlink instead (see section readlink). However, there is one exception: if you have a FSEXT fstat file handler, and do not want do anything special about symlinks. In this case you should call this function from your handler to set properly S_IFLNK bit in st_mode. This function operates on either path or fhandle. In any case, the other arg should be set to NULL or 0.

Return Value

Number of copied characters; value -1 is returned in case of error and errno is set. When value returned is equal to size, you cannot determine if there was enough room to copy whole name. So increase size and try again.

Portability

ANSI/ISO C No
POSIX No

Example

 
char buf[FILENAME_MAX + 1];
if (__internal_readlink(0, "/dev/env/DJDIR/bin/sh.exe",
                        buf, FILENAME_MAX) == -1)
   if (errno == EINVAL)
      puts("/dev/env/DJDIR/bin/sh.exe is not a symbolic link.");


  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004