* ext/pathname/pathname.c (path_realpath): Pathname#realpath translated
from pathname.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b496cd64e5
commit
c29b801afa
@ -1,3 +1,8 @@
|
|||||||
|
Sun Aug 1 20:57:22 2010 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* ext/pathname/pathname.c (path_realpath): Pathname#realpath translated
|
||||||
|
from pathname.rb.
|
||||||
|
|
||||||
Sun Aug 1 17:27:32 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sun Aug 1 17:27:32 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* win32/Makefile.sub: needs stddef.h for size_t. a patch from
|
* win32/Makefile.sub: needs stddef.h for size_t. a patch from
|
||||||
|
@ -179,17 +179,6 @@ class Pathname
|
|||||||
end
|
end
|
||||||
private :cleanpath_conservative
|
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.
|
# Returns the real (absolute) pathname of +self+ in the actual filesystem.
|
||||||
# The real pathname doesn't contain symlinks or useless dots.
|
# The real pathname doesn't contain symlinks or useless dots.
|
||||||
|
@ -198,6 +198,23 @@ path_sub_ext(VALUE self, VALUE repl)
|
|||||||
return rb_class_new_instance(1, &str2, rb_obj_class(self));
|
return rb_class_new_instance(1, &str2, rb_obj_class(self));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
*
|
*
|
||||||
@ -396,4 +413,5 @@ Init_pathname()
|
|||||||
rb_define_method(rb_cPathname, "inspect", path_inspect, 0);
|
rb_define_method(rb_cPathname, "inspect", path_inspect, 0);
|
||||||
rb_define_method(rb_cPathname, "sub", path_sub, -1);
|
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, "sub_ext", path_sub_ext, 1);
|
||||||
|
rb_define_method(rb_cPathname, "realpath", path_realpath, -1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user