www.delorie.com/djgpp/doc/libc/libc_647.html   search  
libc.a reference

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

readlink

Syntax

 
#include <unistd.h>

int readlink(const char *filename, char *buffer, size_t size);

Description

MSDOS doesn't support symbolic links but DJGPP emulates them. This function checks if filename is a DJGPP symlink and the file name that the links points to is copied into buffer, up to maximum size characters. Portable applications should not assume that buffer is terminated with '\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 (readlink("/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   donations   bookstore     delorie software   privacy  
  Copyright 2004   by DJ Delorie     Updated Apr 2004