summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2007-02-27 16:05:49 +0000
committerDarkvater <Darkvater@openttd.org>2007-02-27 16:05:49 +0000
commit0e3d40cababa3201a5f833b1733a59a01890db3b (patch)
treec32359cb0544d7f76ee949975bb1f0e3b941dc7a
parent60866482edf3dee32237b445fcd8bf72a62ea2a9 (diff)
downloadopenttd-0e3d40cababa3201a5f833b1733a59a01890db3b.tar.xz
(svn r8919) -Regression (UTF8) (try #2): Win9x is very picky about trailing slashes in paths, so C:\\* will not work (but C:\Windows\\* does; go figure). Thanks glx for pointing it out and for the initial fix.
-rw-r--r--src/win32.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/win32.cpp b/src/win32.cpp
index dceda5e86..b59621aa6 100644
--- a/src/win32.cpp
+++ b/src/win32.cpp
@@ -665,8 +665,11 @@ DIR *opendir(const wchar_t *path)
d = dir_calloc();
if (d != NULL) {
wchar_t search_path[MAX_PATH];
- /* build search path for FindFirstFile */
- _snwprintf(search_path, lengthof(search_path), L"%s\\*", path);
+ bool slash = path[wcslen(path) - 1] == L'\\';
+
+ /* build search path for FindFirstFile, try not to append additional slashes
+ * as it throws Win9x off its groove for root directories */
+ _snwprintf(search_path, lengthof(search_path), L"%s%s*", path, slash ? L"" : L"\\");
*lastof(search_path) = '\0';
d->hFind = FindFirstFileW(search_path, &d->fd);