summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-06-19 08:38:11 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-06-19 08:38:11 +0000
commitb8148f45947eee7461986536114949556f4eda40 (patch)
tree16ae7f6b7588cc228e0175fe26e4ce15be539c47 /file.c
parentc613f625b7c0c72771d74f86a1177e00290577df (diff)
2000-06-19
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/file.c b/file.c
index 29cea5471d..a5db21ddcc 100644
--- a/file.c
+++ b/file.c
@@ -251,6 +251,53 @@ rb_stat_ctime(self)
return rb_time_new(get_stat(self)->st_ctime, 0);
}
+static VALUE
+rb_stat_inspect(self)
+ VALUE self;
+{
+ VALUE str;
+ int i;
+ struct {
+ char *name;
+ VALUE (*func)();
+ } member[] = {
+ {"dev", rb_stat_dev},
+ {"ino", rb_stat_ino},
+ {"mode", rb_stat_mode},
+ {"nlink", rb_stat_nlink},
+ {"uid", rb_stat_uid},
+ {"gid", rb_stat_gid},
+ {"rdev", rb_stat_rdev},
+ {"size", rb_stat_size},
+ {"blksize", rb_stat_blksize},
+ {"blocks", rb_stat_blocks},
+ {"atime", rb_stat_atime},
+ {"mtime", rb_stat_mtime},
+ {"ctime", rb_stat_ctime},
+ };
+
+ str = rb_str_new2("#<");
+ rb_str_cat2(str, rb_class2name(CLASS_OF(self)));
+ rb_str_cat2(str, " ");
+
+ for (i = 0; i < sizeof(member)/sizeof(member[0]); i++) {
+ VALUE str2;
+ char *p;
+
+ if (i > 0) {
+ rb_str_cat2(str, ", ");
+ }
+ rb_str_cat2(str, member[i].name);
+ rb_str_cat2(str, "=");
+ str2 = rb_inspect((*member[i].func)(self));
+ rb_str_append(str, str2);
+ }
+ rb_str_cat2(str, ">");
+ OBJ_INFECT(str, self);
+
+ return str;
+}
+
static int
rb_stat(file, st)
VALUE file;
@@ -2216,6 +2263,8 @@ Init_File()
rb_define_method(rb_cStat, "mtime", rb_stat_mtime, 0);
rb_define_method(rb_cStat, "ctime", rb_stat_ctime, 0);
+ rb_define_method(rb_cStat, "inspect", rb_stat_inspect, 0);
+
rb_define_method(rb_cStat, "ftype", rb_stat_ftype, 0);
rb_define_method(rb_cStat, "directory?", rb_stat_d, 0);