instance method
File#lstat
() -> (::File::Stat | nil)
lstat → stat
file.c
View on GitHub ↗
static VALUE
rb_file_lstat(VALUE obj)
{
#ifdef HAVE_LSTAT
rb_io_t *fptr;
rb_io_stat_data st;
VALUE path;
GetOpenFile(obj, fptr);
if (NIL_P(fptr->pathv)) return Qnil;
path = rb_str_encode_ospath(fptr->pathv);
if (lstatx_without_gvl(RSTRING_PTR(path), &st, STATX_ALL) == -1) {
rb_sys_fail_path(fptr->pathv);
}
return rb_statx_new(&st);
#else
return rb_io_stat(obj);
#endif
}
Like File#stat, but does not follow the last symbolic link; instead, returns a File::Stat object for the link itself:
Example
File.symlink('t.txt', 'symlink') f = File.new('symlink') f.stat.size # => 47 f.lstat.size # => 11