summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-01-12 00:32:22 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-01-12 00:32:22 +0000
commit853dd6cabe692251376271421be433d68bea2865 (patch)
tree85adecadc51445c95962b556da3f34cfd0c639da /dir.c
parentf86cca6f55ce0e9ec50bc1cb61718d02ebe31e10 (diff)
* prelude.rb (require_relative): use File.realpath. [ruby-dev:40040]
* include/ruby/intern.h: declare rb_dir_getwd. * dir.c (rb_dir_getwd): copied from dir_s_getwd to export. (dir_s_getwd): use rb_dir_getwd. * file.c (rb_file_s_realpath): new method File.realpath. (rb_file_s_realdirpath): new method File.realdirpath. * lib/pathname.rb (Pathname#realpath): use File.realpath. (Pathname#realdirpath): use File.realdirpath. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/dir.c b/dir.c
index e49e9bdc75..c25b33b19d 100644
--- a/dir.c
+++ b/dir.c
@@ -851,6 +851,21 @@ dir_s_chdir(int argc, VALUE *argv, VALUE obj)
return INT2FIX(0);
}
+VALUE
+rb_dir_getwd(void)
+{
+ char *path;
+ VALUE cwd;
+
+ rb_secure(4);
+ path = my_getcwd();
+ cwd = rb_tainted_str_new2(path);
+ rb_enc_associate(cwd, rb_filesystem_encoding());
+
+ xfree(path);
+ return cwd;
+}
+
/*
* call-seq:
* Dir.getwd => string
@@ -865,16 +880,7 @@ dir_s_chdir(int argc, VALUE *argv, VALUE obj)
static VALUE
dir_s_getwd(VALUE dir)
{
- char *path;
- VALUE cwd;
-
- rb_secure(4);
- path = my_getcwd();
- cwd = rb_tainted_str_new2(path);
- rb_enc_associate(cwd, rb_filesystem_encoding());
-
- xfree(path);
- return cwd;
+ return rb_dir_getwd();
}
static void