summaryrefslogtreecommitdiff
path: root/ext/pathname/pathname.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-09-14 11:18:37 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-09-14 11:18:37 +0000
commitbf77099923011a3a0fa0186a8f2dcfb52bdb71bf (patch)
tree951114e95d4a3ddb6fdcbea575d3a40c0f16f5a4 /ext/pathname/pathname.c
parent6d9b5fdffcfe2fc2783c5b03f93e2deb372fd260 (diff)
* 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
Diffstat (limited to 'ext/pathname/pathname.c')
-rw-r--r--ext/pathname/pathname.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c
index eca94b4..9370794 100644
--- a/ext/pathname/pathname.c
+++ b/ext/pathname/pathname.c
@@ -847,6 +847,17 @@ path_s_glob(int argc, VALUE *argv, VALUE klass)
}
/*
+ * See <tt>Dir.getwd</tt>. 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
*
* Pathname represents a pathname which locates a file in a filesystem.
@@ -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);
}