diff options
author | michi_cc <michi_cc@openttd.org> | 2013-04-06 18:36:45 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2013-04-06 18:36:45 +0000 |
commit | 3349cb3347ca566ecd42ae0a29a91fb7dbfb9220 (patch) | |
tree | 3e073073a68c953dc8398657d8df66d745b79d3b /src/os | |
parent | d1212e0b1a66e3ea6a049ef8e985033adb661919 (diff) | |
download | openttd-3349cb3347ca566ecd42ae0a29a91fb7dbfb9220.tar.xz |
(svn r25154) -Fix: [Win32] Don't store invalid paths in the search path list.
Diffstat (limited to 'src/os')
-rw-r--r-- | src/os/windows/win32.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/os/windows/win32.cpp b/src/os/windows/win32.cpp index bf4235346..62f7894d5 100644 --- a/src/os/windows/win32.cpp +++ b/src/os/windows/win32.cpp @@ -505,19 +505,25 @@ void DetermineBasePaths(const char *exe) char tmp[MAX_PATH]; TCHAR path[MAX_PATH]; #ifdef WITH_PERSONAL_DIR - OTTDSHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, path); - strecpy(tmp, WIDE_TO_MB_BUFFER(path, tmp, lengthof(tmp)), lastof(tmp)); - AppendPathSeparator(tmp, MAX_PATH); - ttd_strlcat(tmp, PERSONAL_DIR, MAX_PATH); - AppendPathSeparator(tmp, MAX_PATH); - _searchpaths[SP_PERSONAL_DIR] = strdup(tmp); + if (SUCCEEDED(OTTDSHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, path))) { + strecpy(tmp, WIDE_TO_MB_BUFFER(path, tmp, lengthof(tmp)), lastof(tmp)); + AppendPathSeparator(tmp, MAX_PATH); + ttd_strlcat(tmp, PERSONAL_DIR, MAX_PATH); + AppendPathSeparator(tmp, MAX_PATH); + _searchpaths[SP_PERSONAL_DIR] = strdup(tmp); + } else { + _searchpaths[SP_PERSONAL_DIR] = NULL; + } - OTTDSHGetFolderPath(NULL, CSIDL_COMMON_DOCUMENTS, NULL, SHGFP_TYPE_CURRENT, path); - strecpy(tmp, WIDE_TO_MB_BUFFER(path, tmp, lengthof(tmp)), lastof(tmp)); - AppendPathSeparator(tmp, MAX_PATH); - ttd_strlcat(tmp, PERSONAL_DIR, MAX_PATH); - AppendPathSeparator(tmp, MAX_PATH); - _searchpaths[SP_SHARED_DIR] = strdup(tmp); + if (SUCCEEDED(OTTDSHGetFolderPath(NULL, CSIDL_COMMON_DOCUMENTS, NULL, SHGFP_TYPE_CURRENT, path))) { + strecpy(tmp, WIDE_TO_MB_BUFFER(path, tmp, lengthof(tmp)), lastof(tmp)); + AppendPathSeparator(tmp, MAX_PATH); + ttd_strlcat(tmp, PERSONAL_DIR, MAX_PATH); + AppendPathSeparator(tmp, MAX_PATH); + _searchpaths[SP_SHARED_DIR] = strdup(tmp); + } else { + _searchpaths[SP_SHARED_DIR] = NULL; + } #else _searchpaths[SP_PERSONAL_DIR] = NULL; _searchpaths[SP_SHARED_DIR] = NULL; |