summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-16 10:25:56 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-16 10:25:56 +0000
commit000482a1730757f1cf0ba7e8874decbaebb90a4a (patch)
tree9e434fa2825253d62a2f175957ec2c834bea4e36 /dir.c
parent87acdae43dcfab5d28c85b10374be9faf6209076 (diff)
rb_w32_ugetcwd: UTF-8 version getcwd
* dir.c (rb_dir_getwd): convert from UTF-8. * win32/win32.c (w32_getcwd): codepage aware getcwd using GetCurrentDirectoryW. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/dir.c b/dir.c
index e568ab0..50a8b18 100644
--- a/dir.c
+++ b/dir.c
@@ -74,6 +74,7 @@ char *strchr(char*,char);
#define rmdir(p) rb_w32_urmdir(p)
#undef opendir
#define opendir(p) rb_w32_uopendir(p)
+#define ruby_getcwd() rb_w32_ugetcwd(NULL, 0)
#define IS_WIN32 1
#else
#define IS_WIN32 0
@@ -1051,10 +1052,14 @@ rb_dir_getwd(void)
{
char *path;
VALUE cwd;
- int fsenc = rb_enc_to_index(rb_filesystem_encoding());
+ rb_encoding *fs = rb_filesystem_encoding();
+ int fsenc = rb_enc_to_index(fs);
if (fsenc == ENCINDEX_US_ASCII) fsenc = ENCINDEX_ASCII;
path = my_getcwd();
+#ifdef _WIN32
+ cwd = rb_str_conv_enc(rb_utf8_str_new_cstr(path), NULL, fs);
+#else
#ifdef __APPLE__
cwd = rb_str_normalize_ospath(path, strlen(path));
OBJ_TAINT(cwd);
@@ -1062,6 +1067,7 @@ rb_dir_getwd(void)
cwd = rb_tainted_str_new2(path);
#endif
rb_enc_associate_index(cwd, fsenc);
+#endif
xfree(path);
return cwd;