aboutsummaryrefslogtreecommitdiffstats
path: root/dir.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-02 22:13:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-02 22:13:17 +0000
commit8d031a7a862620e15e66e6fc104a46cb9f3cf1f2 (patch)
treed9669ca84cad6fc84b1324a84ca7c23fc444bf03 /dir.c
parentd352ec2c7a32c8a03eb16e84d52e0e3412a28432 (diff)
downloadruby-8d031a7a862620e15e66e6fc104a46cb9f3cf1f2.tar.gz
dir.c: set errno
* dir.c (replace_real_basename): Win32 API does not set errno, get the last error by GetLastError() and map to errno. [Bug #10015] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/dir.c b/dir.c
index ce8cb6324a..9b62cb3e07 100644
--- a/dir.c
+++ b/dir.c
@@ -1525,6 +1525,7 @@ replace_real_basename(char *path, long base, rb_encoding *enc, int norm_p, int f
WCHAR *wplain;
HANDLE h = INVALID_HANDLE_VALUE;
long wlen;
+ int e = 0;
if (enc &&
enc != rb_usascii_encoding() &&
enc != rb_ascii8bit_encoding() &&
@@ -1536,13 +1537,17 @@ replace_real_basename(char *path, long base, rb_encoding *enc, int norm_p, int f
wplain = rb_w32_mbstr_to_wstr(CP_UTF8, plainname, -1, &wlen);
if (tmp) rb_str_resize(tmp, 0);
if (!wplain) return path;
- if (GetFileAttributesExW(wplain, GetFileExInfoStandard, &fa))
+ if (GetFileAttributesExW(wplain, GetFileExInfoStandard, &fa)) {
h = FindFirstFileW(wplain, &fd);
+ e = rb_w32_map_errno(GetLastError());
+ }
free(wplain);
if (h == INVALID_HANDLE_VALUE) {
*type = path_noent;
- if (!to_be_ignored(errno))
+ if (e && !to_be_ignored(e)) {
+ errno = e;
sys_warning(path, enc);
+ }
return path;
}
FindClose(h);