From bf77099923011a3a0fa0186a8f2dcfb52bdb71bf Mon Sep 17 00:00:00 2001 From: akr Date: Tue, 14 Sep 2010 11:18:37 +0000 Subject: * ext/pathname/pathname.c (path_s_getwd): Pathname.getwd and Pathname.pwd translated from pathname.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/pathname/lib/pathname.rb | 3 --- ext/pathname/pathname.c | 13 +++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'ext/pathname') diff --git a/ext/pathname/lib/pathname.rb b/ext/pathname/lib/pathname.rb index e519dd56d2..0efb5d4eb0 100644 --- a/ext/pathname/lib/pathname.rb +++ b/ext/pathname/lib/pathname.rb @@ -485,9 +485,6 @@ end class Pathname # * Dir * - # See Dir.getwd. Returns the current working directory as a Pathname. - def Pathname.getwd() self.new(Dir.getwd) end - class << self; alias pwd getwd end # Return the entries (files and subdirectories) in the directory, each as a # Pathname object. diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c index eca94b4d16..9370794a8c 100644 --- a/ext/pathname/pathname.c +++ b/ext/pathname/pathname.c @@ -846,6 +846,17 @@ path_s_glob(int argc, VALUE *argv, VALUE klass) } } +/* + * See Dir.getwd. Returns the current working directory as a Pathname. + */ +static VALUE +path_s_getwd(VALUE klass) +{ + VALUE str; + str = rb_funcall(rb_cDir, rb_intern("getwd"), 0); + return rb_class_new_instance(1, &str, klass); +} + /* * == Pathname * @@ -1100,4 +1111,6 @@ Init_pathname() rb_define_method(rb_cPathname, "writable_real?", path_writable_real_p, 0); rb_define_method(rb_cPathname, "zero?", path_zero_p, 0); rb_define_singleton_method(rb_cPathname, "glob", path_s_glob, -1); + rb_define_singleton_method(rb_cPathname, "getwd", path_s_getwd, 0); + rb_define_singleton_method(rb_cPathname, "pwd", path_s_getwd, 0); } -- cgit v1.2.3