diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-04 02:33:37 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-04 02:33:37 +0000 |
commit | 79e0379a7573e998d52ea42242ea0cc96fa81738 (patch) | |
tree | fe5c02065ba78465a7b6811109954f6a1b289667 /win32 | |
parent | bd895ab17616bfae882990e302aa1b9036043129 (diff) |
* win32/win32.c (check_valid_dir): special case for a root directory.
Reported by Masateru OKAMOTO at [Bug #5819].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r-- | win32/win32.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/win32/win32.c b/win32/win32.c index 79df655e43..62c3076d73 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -4475,7 +4475,20 @@ static int check_valid_dir(const WCHAR *path) { WIN32_FIND_DATAW fd; - HANDLE fh = open_dir_handle(path, &fd); + HANDLE fh; + WCHAR full[MAX_PATH]; + WCHAR *dmy; + + /* if the specified path is the root of a drive and the drive is empty, */ + /* FindFirstFile() returns INVALID_HANDLE_VALUE. */ + if (!GetFullPathNameW(path, sizeof(full) / sizeof(WCHAR), full, &dmy)) { + errno = map_errno(GetLastError()); + return -1; + } + if (GetDriveTypeW(full) != DRIVE_NO_ROOT_DIR) + return 0; + + fh = open_dir_handle(path, &fd); if (fh == INVALID_HANDLE_VALUE) return -1; FindClose(fh); |