lstat()
public
Show source
/*
* 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")
* File.stat("testfile").size
* f = File.new("link2test")
* f.lstat.size
* f.stat.size
*/
static VALUE
rb_file_lstat(obj)
VALUE obj;
{
#ifdef HAVE_LSTAT
rb_io_t *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
}