* ext/pathname/pathname.c (path_dirname): Pathname#dirname translated
from pathname.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1572070fa0
commit
05745ccfb3
@ -1,3 +1,8 @@
|
||||
Tue Aug 17 13:00:07 2010 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/pathname/pathname.c (path_dirname): Pathname#dirname translated
|
||||
from pathname.rb.
|
||||
|
||||
Tue Aug 17 07:50:37 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/readline/extconf.rb: check functions more.
|
||||
|
@ -512,9 +512,6 @@ end
|
||||
|
||||
class Pathname # * File *
|
||||
|
||||
# See <tt>File.dirname</tt>. Returns all but the last component of the path.
|
||||
def dirname() self.class.new(File.dirname(@path)) end
|
||||
|
||||
# See <tt>File.extname</tt>. Returns the file's extension.
|
||||
def extname() File.extname(@path) end
|
||||
|
||||
|
@ -438,6 +438,17 @@ path_basename(int argc, VALUE *argv, VALUE self)
|
||||
return rb_class_new_instance(1, &str, rb_obj_class(self));
|
||||
}
|
||||
|
||||
/*
|
||||
* See <tt>File.dirname</tt>. Returns all but the last component of the path.
|
||||
*/
|
||||
static VALUE
|
||||
path_dirname(VALUE self)
|
||||
{
|
||||
VALUE str = get_strpath(self);
|
||||
str = rb_funcall(rb_cFile, rb_intern("dirname"), 1, str);
|
||||
return rb_class_new_instance(1, &str, rb_obj_class(self));
|
||||
}
|
||||
|
||||
/*
|
||||
* == Pathname
|
||||
*
|
||||
@ -658,4 +669,5 @@ Init_pathname()
|
||||
rb_define_method(rb_cPathname, "truncate", path_truncate, 1);
|
||||
rb_define_method(rb_cPathname, "utime", path_utime, 2);
|
||||
rb_define_method(rb_cPathname, "basename", path_basename, -1);
|
||||
rb_define_method(rb_cPathname, "dirname", path_dirname, 0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user