summaryrefslogtreecommitdiff
path: root/win32/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-26 11:37:01 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-26 11:37:01 +0000
commit6b88dd2698760ef2e2306e3e79a0ed9fe159a12c (patch)
treecd3b580d1449865c3023ab6d7bdea068d8245c78 /win32/file.c
parent58742627af428650799118179639b2793372819a (diff)
file.c: home directory from system
* file.c (rb_default_home_dir): resolve home directory from the system database when HOME is not set. [Feature #12695] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32/file.c')
-rw-r--r--win32/file.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/win32/file.c b/win32/file.c
index c0efb7b0919..b50c61292df 100644
--- a/win32/file.c
+++ b/win32/file.c
@@ -237,6 +237,19 @@ append_wstr(VALUE dst, const WCHAR *ws, ssize_t len, UINT cp, rb_encoding *enc)
}
VALUE
+rb_default_home_dir(VALUE result)
+{
+ const WCHAR *dir = rb_w32_home_dir();
+ if (!dir) {
+ rb_raise(rb_eArgError, "couldn't find HOME environment -- expanding `~'");
+ }
+ append_wstr(result, dir, -1,
+ rb_w32_filecp(), rb_filesystem_encoding());
+ xfree(dir);
+ return result;
+}
+
+VALUE
rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_name, VALUE result)
{
size_t size = 0, whome_len = 0;