Method: File::Stat#initialize

Defined in:
file.c

#File::Stat.new(file_name) ⇒ Object

Create a File::Stat object for the given file name (raising an exception if the file doesn’t exist).



5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
# File 'file.c', line 5689

static VALUE
rb_stat_init(VALUE obj, VALUE fname)
{
    struct stat st;

    FilePathValue(fname);
    fname = rb_str_encode_ospath(fname);
    if (STAT(StringValueCStr(fname), &st) == -1) {
        rb_sys_fail_path(fname);
    }

    struct rb_stat *rb_st;
    TypedData_Get_Struct(obj, struct rb_stat, &stat_data_type, rb_st);

    rb_st->stat = st;
    rb_st->initialized = true;

    return Qnil;
}