summaryrefslogtreecommitdiff
path: root/src/os
diff options
context:
space:
mode:
Diffstat (limited to 'src/os')
-rw-r--r--src/os/windows/win32.cpp30
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;