diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ext/pathname/lib/pathname.rb | 4 | ||||
-rw-r--r-- | ext/pathname/pathname.c | 11 |
3 files changed, 16 insertions, 4 deletions
@@ -1,3 +1,8 @@ +Sun Aug 8 13:20:57 2010 Tanaka Akira <akr@fsij.org> + + * ext/pathname/pathname.c (path_ftype): Pathname#ftype translated + from pathname.rb. + Sun Aug 8 12:41:19 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> * parse.y (parser_tokadd_escape): no similar messages twice. diff --git a/ext/pathname/lib/pathname.rb b/ext/pathname/lib/pathname.rb index d2373ebdb1..d2d3d8ac21 100644 --- a/ext/pathname/lib/pathname.rb +++ b/ext/pathname/lib/pathname.rb @@ -512,10 +512,6 @@ end class Pathname # * File * - # See <tt>File.ftype</tt>. Returns "type" of file ("file", "directory", - # etc). - def ftype() File.ftype(@path) end - # See <tt>File.link</tt>. Creates a hard link. def make_link(old) File.link(old, @path) end diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c index 81b6d23e6d..4ed17f4efd 100644 --- a/ext/pathname/pathname.c +++ b/ext/pathname/pathname.c @@ -315,6 +315,16 @@ path_fnmatch(int argc, VALUE *argv, VALUE self) } /* + * See <tt>File.ftype</tt>. Returns "type" of file ("file", "directory", + * etc). + */ +static VALUE +path_ftype(VALUE self) +{ + return rb_funcall(rb_cFile, rb_intern("ftype"), 1, get_strpath(self)); +} + +/* * == Pathname * * Pathname represents a pathname which locates a file in a filesystem. @@ -523,4 +533,5 @@ Init_pathname() rb_define_method(rb_cPathname, "lchown", path_lchown, 2); rb_define_method(rb_cPathname, "fnmatch", path_fnmatch, -1); rb_define_method(rb_cPathname, "fnmatch?", path_fnmatch, -1); + rb_define_method(rb_cPathname, "ftype", path_ftype, 0); } |