summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-26 04:04:23 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-26 04:04:23 +0000
commit8948280c67072f652eebc31bc3a2f3fb86bcca5f (patch)
tree8e433b03c6bc0f19f1a166b53d8aea0430e24c97 /win32
parent2c181b6d1a0514204e049e5f37529b8b8ccfe434 (diff)
load.c: search in OS path encoding
* load.c (rb_load_internal): use rb_load_file_str() to keep path encoding. * load.c (rb_require_safe): search in OS path encoding for Windows. * ruby.c (rb_load_file_str): load file with keeping path encoding. * win32/file.c (rb_file_load_ok): use WCHAR type API assuming incoming path is encoded in UTF-8. [ruby-core:56136] [Bug #8676] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/file.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/win32/file.c b/win32/file.c
index f7b419530f..d43db14c50 100644
--- a/win32/file.c
+++ b/win32/file.c
@@ -681,16 +681,22 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na
int
rb_file_load_ok(const char *path)
{
+ DWORD attr;
int ret = 1;
- DWORD attr = GetFileAttributes(path);
+ size_t len;
+ wchar_t* wpath;
+
+ convert_mb_to_wchar(path, &wpath, &len, CP_UTF8);
+
+ attr = GetFileAttributesW(wpath);
if (attr == INVALID_FILE_ATTRIBUTES ||
- attr & FILE_ATTRIBUTE_DIRECTORY) {
+ (attr & FILE_ATTRIBUTE_DIRECTORY)) {
ret = 0;
}
else {
- HANDLE h = CreateFile(path, GENERIC_READ,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ HANDLE h = CreateFileW(wpath, GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (h != INVALID_HANDLE_VALUE) {
CloseHandle(h);
}
@@ -698,6 +704,7 @@ rb_file_load_ok(const char *path)
ret = 0;
}
}
+ xfree(wpath);
return ret;
}