summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-17 02:23:52 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-17 02:23:52 +0000
commite98d5d4f66f51f34629392ef5831cc4667502216 (patch)
treedd786449619d584beeab06c4f89820a7c06df73c /file.c
parent865cd4fc392cb20b7959b4c425f5a2ec52c92df2 (diff)
* eval.c (THREAD_ALLOC): th->thread should be initialized to NULL.
[ruby-talk:106657] The solution was found by Guy Decoux. * file.c (rb_stat_dev_major): new methods File::Stat#dev_major and #dev_minor. [ruby-core:03195] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/file.c b/file.c
index afc364e..7f5452b 100644
--- a/file.c
+++ b/file.c
@@ -192,6 +192,52 @@ rb_stat_dev(self)
return INT2NUM(get_stat(self)->st_dev);
}
+/*
+ * call-seq:
+ * stat.dev_major => fixnum
+ *
+ * Returns the major part of <code>File_Stat#dev</code> or
+ * <code>nil</code>.
+ *
+ * File.stat("/dev/fd1").dev_major #=> 2
+ * File.stat("/dev/tty").dev_major #=> 5
+ */
+
+static VALUE
+rb_stat_dev_major(self)
+ VALUE self;
+{
+#if defined(major)
+ long dev = get_stat(self)->st_dev;
+ return ULONG2NUM(major(dev));
+#else
+ return Qnil;
+#endif
+}
+
+/*
+ * call-seq:
+ * stat.dev_minor => fixnum
+ *
+ * Returns the minor part of <code>File_Stat#dev</code> or
+ * <code>nil</code>.
+ *
+ * File.stat("/dev/fd1").dev_minor #=> 1
+ * File.stat("/dev/tty").dev_minor #=> 0
+ */
+
+static VALUE
+rb_stat_dev_minor(self)
+ VALUE self;
+{
+#if defined(minor)
+ long dev = get_stat(self)->st_dev;
+ return ULONG2NUM(minor(dev));
+#else
+ return Qnil;
+#endif
+}
+
/*
* call-seq:
@@ -4148,6 +4194,8 @@ Init_File()
rb_define_method(rb_cStat, "<=>", rb_stat_cmp, 1);
rb_define_method(rb_cStat, "dev", rb_stat_dev, 0);
+ rb_define_method(rb_cStat, "dev_major", rb_stat_dev_major, 0);
+ rb_define_method(rb_cStat, "dev_minor", rb_stat_dev_minor, 0);
rb_define_method(rb_cStat, "ino", rb_stat_ino, 0);
rb_define_method(rb_cStat, "mode", rb_stat_mode, 0);
rb_define_method(rb_cStat, "nlink", rb_stat_nlink, 0);