diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-26 04:51:27 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-26 04:51:27 +0000 |
commit | 7a0d81eaa25edf97a413c85e5560a05a30aaa5ad (patch) | |
tree | 9520df31852c0e6a55cd316c26cb25e7ca7e14e1 /win32 | |
parent | 06fba52338e439fdaca5ddf0b35947259aaa7a1c (diff) | |
download | ruby-7a0d81eaa25edf97a413c85e5560a05a30aaa5ad.tar.gz |
* win32/win32.c (check_if_dir, check_if_wdir): fix for Visual C++
not to use S_ISDIR(). [Feature #2408][ruby-core:26925]
* ruby.c (load_file_internal): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r-- | win32/win32.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/win32/win32.c b/win32/win32.c index 2657d7403d..c26d3e3cc7 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -5188,9 +5188,18 @@ rb_w32_uopen(const char *file, int oflag, ...) static int check_if_dir(const char *file) { - struct stati64 st; - if (rb_w32_stati64(file, &st) != 0 || !S_ISDIR(st.st_mode)) + DWORD attr; + WCHAR *wfile; + + if (!(wfile = filecp_to_wstr(file, NULL))) + return FALSE; + attr = GetFileAttributesW(wfile); + if (attr == (DWORD)-1L || + !(attr & FILE_ATTRIBUTE_DIRECTORY) || + check_valid_dir(wfile)) { return FALSE; + } + free(wfile); errno = EISDIR; return TRUE; } @@ -5199,9 +5208,12 @@ check_if_dir(const char *file) static int check_if_wdir(const WCHAR *wfile) { - struct stati64 st; - if (wstati64(wfile, &st) != 0 || !S_ISDIR(st.st_mode)) + DWORD attr = GetFileAttributesW(wfile); + if (attr == (DWORD)-1L || + !(attr & FILE_ATTRIBUTE_DIRECTORY) || + check_valid_dir(wfile)) { return FALSE; + } errno = EISDIR; return TRUE; } |