From 88431b74fcb16e92e67ec3d3abf205793b255772 Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 1 Aug 2010 20:35:33 +0000 Subject: * ext/pathname/pathname.c (path_realdirpath): Pathname#realdirpath translated from pathname.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/pathname/pathname.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'ext/pathname/pathname.c') diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c index 273ecee07c..d4fd502674 100644 --- a/ext/pathname/pathname.c +++ b/ext/pathname/pathname.c @@ -215,6 +215,21 @@ path_realpath(int argc, VALUE *argv, VALUE self) return rb_class_new_instance(1, &str, rb_obj_class(self)); } +/* + * Returns the real (absolute) pathname of +self+ in the actual filesystem. + * The real pathname doesn't contain symlinks or useless dots. + * + * The last component of the real pathname can be nonexistent. + */ +static VALUE +path_realdirpath(int argc, VALUE *argv, VALUE self) +{ + VALUE basedir, str; + rb_scan_args(argc, argv, "01", &basedir); + str = rb_funcall(rb_cFile, rb_intern("realdirpath"), 2, get_strpath(self), basedir); + return rb_class_new_instance(1, &str, rb_obj_class(self)); +} + /* * == Pathname * @@ -414,4 +429,5 @@ Init_pathname() rb_define_method(rb_cPathname, "sub", path_sub, -1); rb_define_method(rb_cPathname, "sub_ext", path_sub_ext, 1); rb_define_method(rb_cPathname, "realpath", path_realpath, -1); + rb_define_method(rb_cPathname, "realdirpath", path_realdirpath, -1); } -- cgit v1.2.3