summaryrefslogtreecommitdiff
path: root/ext/pathname/pathname.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-20 01:40:51 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-20 01:40:51 +0000
commit19fb560d219f583066241293f2e0f92cd898595e (patch)
tree63c015fc3945906077e2489c587fa800b9c2160a /ext/pathname/pathname.c
parent1fa5a50cd05de69d94815757da628eab29471a1f (diff)
* ext/pathname/pathname.c (path_expand_path): Pathname#expand_path
translated from pathname.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/pathname/pathname.c')
-rw-r--r--ext/pathname/pathname.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c
index 834fa446da..2ebb976de2 100644
--- a/ext/pathname/pathname.c
+++ b/ext/pathname/pathname.c
@@ -460,6 +460,21 @@ path_extname(VALUE self)
}
/*
+ * See <tt>File.expand_path</tt>.
+ */
+static VALUE
+path_expand_path(int argc, VALUE *argv, VALUE self)
+{
+ VALUE str = get_strpath(self);
+ VALUE dname;
+ if (rb_scan_args(argc, argv, "01", &dname) == 0)
+ str = rb_funcall(rb_cFile, rb_intern("expand_path"), 1, str);
+ else
+ str = rb_funcall(rb_cFile, rb_intern("expand_path"), 2, str, dname);
+ return rb_class_new_instance(1, &str, rb_obj_class(self));
+}
+
+/*
* == Pathname
*
* Pathname represents a pathname which locates a file in a filesystem.
@@ -681,4 +696,5 @@ Init_pathname()
rb_define_method(rb_cPathname, "basename", path_basename, -1);
rb_define_method(rb_cPathname, "dirname", path_dirname, 0);
rb_define_method(rb_cPathname, "extname", path_extname, 0);
+ rb_define_method(rb_cPathname, "expand_path", path_expand_path, -1);
}