method
lstat
ruby latest stable - Class:
File
lstat()public
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
static VALUE
rb_file_lstat(VALUE obj)
{
#ifdef HAVE_LSTAT
rb_io_t *fptr;
struct stat st;
VALUE path;
GetOpenFile(obj, fptr);
if (NIL_P(fptr->pathv)) return Qnil;
path = rb_str_encode_ospath(fptr->pathv);
if (lstat_without_gvl(RSTRING_PTR(path), &st) == -1) {
rb_sys_fail_path(fptr->pathv);
}
return rb_stat_new(&st);
#else
return rb_io_stat(obj);
#endif
}