public Method

File.lstat

file.lstat     stat

Same as IO#stat, but does not follow the last symbolic link. Instead, reports on the link itself.

File.symlink("testfile", "link2test")   #=> 0
File.stat("testfile").size              #=> 66
f = File.new("link2test")
f.lstat.size                            #=> 8
f.stat.size                             #=> 66

Source Code

/*
*  call-seq:
*     file.lstat   =>  stat
*  
*  Same as <code>IO#stat</code>, but does not follow the last symbolic
*  link. Instead, reports on the link itself.
*     
*     File.symlink("testfile", "link2test")   #=> 0
*     File.stat("testfile").size              #=> 66
*     f = File.new("link2test")
*     f.lstat.size                            #=> 8
*     f.stat.size                             #=> 66
*/

static VALUE
rb_file_lstat(obj)
   VALUE obj;
{
#ifdef HAVE_LSTAT
   OpenFile *fptr;
   struct stat st;

   rb_secure(2);
   GetOpenFile(obj, fptr);
   if (!fptr->path) return Qnil;
   if (lstat(fptr->path, &st) == -1) {
       rb_sys_fail(fptr->path);
   }
   return stat_new(&st);
#else
   return rb_io_stat(obj);
#endif
}
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.