public Method

Stat.symlink?

stat.symlink?     true or false

Returns true if stat is a symbolic link, false if it isn’t or if the operating system doesn’t support this feature. As File::stat automatically follows symbolic links, symlink? will always be false for an object returned by File::stat.

File.symlink("testfile", "alink")   #=> 0
File.stat("alink").symlink?         #=> false
File.lstat("alink").symlink?        #=> true

Source Code

/*
*  call-seq:
*     stat.symlink?    => true or false
*  
*  Returns <code>true</code> if <i>stat</i> is a symbolic link,
*  <code>false</code> if it isn't or if the operating system doesn't
*  support this feature. As <code>File::stat</code> automatically
*  follows symbolic links, <code>symlink?</code> will always be
*  <code>false</code> for an object returned by
*  <code>File::stat</code>.
*     
*     File.symlink("testfile", "alink")   #=> 0
*     File.stat("alink").symlink?         #=> false
*     File.lstat("alink").symlink?        #=> true
*     
*/

static VALUE
rb_stat_l(obj)
   VALUE obj;
{
#ifdef S_ISLNK
   if (S_ISLNK(get_stat(obj)->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.