summaryrefslogtreecommitdiff
path: root/src/win32.cpp
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2007-02-20 00:09:23 +0000
committerDarkvater <darkvater@openttd.org>2007-02-20 00:09:23 +0000
commit92bbe45dd031c7a14b9ba55a77a27d66cf07b876 (patch)
tree2597b59d39104907743caf0340df546274f0b559 /src/win32.cpp
parent5b237758aaf4ba5d646ccfad2129312f30bfcfb2 (diff)
downloadopenttd-92bbe45dd031c7a14b9ba55a77a27d66cf07b876.tar.xz
(svn r8821) -Regression: Unable to browse directories on *nix if the filesystem is not in UTF-8 charset and special characters are used. The string passed to opendir() which is UTF-8 was not parsed back to the filesystem format. Use a wrapper called ttd_opendir() instead of redefining opendir itself.
Diffstat (limited to 'src/win32.cpp')
-rw-r--r--src/win32.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/win32.cpp b/src/win32.cpp
index a79fda13a..017d62a2c 100644
--- a/src/win32.cpp
+++ b/src/win32.cpp
@@ -653,19 +653,19 @@ static inline void dir_free(DIR *d)
}
}
-DIR *opendir(const char *path)
+DIR *opendir(const wchar_t *path)
{
DIR *d;
UINT sem = SetErrorMode(SEM_FAILCRITICALERRORS); // disable 'no-disk' message box
- DWORD fa = GetFileAttributesW(OTTD2FS(path));
+ DWORD fa = GetFileAttributesW(path);
if ((fa != INVALID_FILE_ATTRIBUTES) && (fa & FILE_ATTRIBUTE_DIRECTORY)) {
d = dir_calloc();
if (d != NULL) {
- char search_path[MAX_PATH];
+ wchar_t search_path[MAX_PATH];
/* build search path for FindFirstFile */
- snprintf(search_path, lengthof(search_path), "%s" PATHSEP "*", path);
- d->hFind = FindFirstFileW(OTTD2FS(search_path), &d->fd);
+ _snwprintf_s(search_path, lengthof(search_path), L"%s\\*", path);
+ d->hFind = FindFirstFileW(search_path, &d->fd);
if (d->hFind != INVALID_HANDLE_VALUE ||
GetLastError() == ERROR_NO_MORE_FILES) { // the directory is empty