aboutsummaryrefslogtreecommitdiffstats
path: root/dir.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-25 04:06:50 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-25 04:06:50 +0000
commit7ec4a44762e63b75120ecc5154a00828c8f31b01 (patch)
tree3121babc149fe568f45db08661b1ee56e11d659c /dir.c
parentdda113e3ff954064f718c73a114bb01361b5d205 (diff)
downloadruby-7ec4a44762e63b75120ecc5154a00828c8f31b01.tar.gz
file.c: split rb_home_dir
* dir.c (dir_s_home): use rb_home_dir_of and rb_default_home_dir. * file.c (rb_home_dir_of): split from rb_home_dir() for the home directry of the given user, and the user name is a VALUE, not a bare pointer. should raise if the user does not exist. * file.c (rb_default_home_dir): split from rb_home_dir() for the home directry of the current user. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/dir.c b/dir.c
index d4376ef7d6..403e68be43 100644
--- a/dir.c
+++ b/dir.c
@@ -2125,12 +2125,18 @@ dir_s_home(int argc, VALUE *argv, VALUE obj)
VALUE user;
const char *u = 0;
- rb_scan_args(argc, argv, "01", &user);
+ rb_check_arity(argc, 0, 1);
+ user = (argc > 0) argv[0] : Qnil;
if (!NIL_P(user)) {
SafeStringValue(user);
+ rb_must_asciicompat(user);
u = StringValueCStr(user);
+ if (*u) {
+ return rb_home_dir_of(user, rb_str_new(0, 0));
+ }
}
- return rb_home_dir(u, rb_str_new(0, 0));
+ return rb_default_home_dir(rb_str_new(0, 0));
+
}
#if 0