ruby-changes:16828
From: akr <ko1@a...>
Date: Sun, 1 Aug 2010 20:58:22 +0900 (JST)
Subject: [ruby-changes:16828] Ruby:r28823 (trunk): * ext/pathname/pathname.c (path_realpath): Pathname#realpath translated
akr 2010-08-01 20:57:58 +0900 (Sun, 01 Aug 2010) New Revision: 28823 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28823 Log: * ext/pathname/pathname.c (path_realpath): Pathname#realpath translated from pathname.rb. Modified files: trunk/ChangeLog trunk/ext/pathname/lib/pathname.rb trunk/ext/pathname/pathname.c Index: ChangeLog =================================================================== --- ChangeLog (revision 28822) +++ ChangeLog (revision 28823) @@ -1,3 +1,8 @@ +Sun Aug 1 20:57:22 2010 Tanaka Akira <akr@f...> + + * ext/pathname/pathname.c (path_realpath): Pathname#realpath translated + from pathname.rb. + Sun Aug 1 17:27:32 2010 Nobuyoshi Nakada <nobu@r...> * win32/Makefile.sub: needs stddef.h for size_t. a patch from Index: ext/pathname/lib/pathname.rb =================================================================== --- ext/pathname/lib/pathname.rb (revision 28822) +++ ext/pathname/lib/pathname.rb (revision 28823) @@ -180,17 +180,6 @@ private :cleanpath_conservative # - # Returns the real (absolute) pathname of +self+ in the actual - # filesystem not containing symlinks or useless dots. - # - # All components of the pathname must exist when this method is - # called. - # - def realpath(basedir=nil) - self.class.new(File.realpath(@path, basedir)) - end - - # # Returns the real (absolute) pathname of +self+ in the actual filesystem. # The real pathname doesn't contain symlinks or useless dots. # Index: ext/pathname/pathname.c =================================================================== --- ext/pathname/pathname.c (revision 28822) +++ ext/pathname/pathname.c (revision 28823) @@ -199,6 +199,23 @@ } /* + * Returns the real (absolute) pathname of +self+ in the actual + * filesystem not containing symlinks or useless dots. + * + * All components of the pathname must exist when this method is + * called. + * + */ +static VALUE +path_realpath(int argc, VALUE *argv, VALUE self) +{ + VALUE basedir, str; + rb_scan_args(argc, argv, "01", &basedir); + str = rb_funcall(rb_cFile, rb_intern("realpath"), 2, get_strpath(self), basedir); + return rb_class_new_instance(1, &str, rb_obj_class(self)); +} + +/* * == Pathname * * Pathname represents a pathname which locates a file in a filesystem. @@ -396,4 +413,5 @@ rb_define_method(rb_cPathname, "inspect", path_inspect, 0); 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); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/