static public Method

File.symlink?(p1)

File.symlink?(file_name)     true or false

Returns true if the named file is a symbolic link.

Source Code

/*
* call-seq:
*   File.symlink?(file_name)   =>  true or false
*
* Returns <code>true</code> if the named file is a symbolic link.
*/

static VALUE
test_l(obj, fname)
   VALUE obj, fname;
{
#ifndef S_ISLNK
#  ifdef _S_ISLNK
#    define S_ISLNK(m) _S_ISLNK(m)
#  elif defined __BORLANDC__
#    ifdef _S_IFLNK
#      define S_ISLNK(m) (((unsigned short)(m) & S_IFMT) == _S_IFLNK)
#    else
#      ifdef S_IFLNK
#        define S_ISLNK(m) (((unsigned short)(m) & S_IFMT) == S_IFLNK)
#      endif
#    endif
#  else
#    ifdef _S_IFLNK
#      define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
#    else
#      ifdef S_IFLNK
#        define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
#      endif
#    endif
#  endif
#endif

#ifdef S_ISLNK
   struct stat st;

   SafeStringValue(fname);
   if (lstat(StringValueCStr(fname), &st) < 0) return Qfalse;
   if (S_ISLNK(st.st_mode)) return Qtrue;
#endif

   return Qfalse;
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.