diff options
author | Luke Dashjr <luke-jr+git@utopios.org> | 2012-03-03 13:59:19 -0500 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2012-03-03 13:59:19 -0500 |
commit | 7013cc3d9710c0a03f6587c854e4e50c358ea70c (patch) | |
tree | 35e3c2ff533126be6d8d495eb6cf33d62b609014 /src/util.cpp | |
parent | ef48e9b7dfde66368c27ed34f5f42de1b8e781f9 (diff) | |
parent | 88aa771536014919e955c4f7b2cada9a0dcf8561 (diff) | |
download | bitcoin-7013cc3d9710c0a03f6587c854e4e50c358ea70c.tar.xz |
Merge branch '0.4.x' into 0.5.0.x
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/util.cpp b/src/util.cpp index b17166a0ee..f6c37a2d1f 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -737,26 +737,35 @@ string MyGetSpecialFolderPath(int nFolder, bool fCreate) { PSHGETSPECIALFOLDERPATHA pSHGetSpecialFolderPath = (PSHGETSPECIALFOLDERPATHA)GetProcAddress(hShell32, "SHGetSpecialFolderPathA"); + bool fSuccess = false; if (pSHGetSpecialFolderPath) + fSuccess = (*pSHGetSpecialFolderPath)(NULL, pszPath, nFolder, fCreate); FreeModule(hShell32); + if (fSuccess) + return pszPath; } // Backup option - if (pszPath[0] == '\0') + std::string strPath; { + const char *pszEnv; if (nFolder == CSIDL_STARTUP) { - strcpy(pszPath, getenv("USERPROFILE")); - strcat(pszPath, "\\Start Menu\\Programs\\Startup"); + pszEnv = getenv("USERPROFILE"); + if (pszEnv) + strPath = pszEnv; + strPath += "\\Start Menu\\Programs\\Startup"; } else if (nFolder == CSIDL_APPDATA) { - strcpy(pszPath, getenv("APPDATA")); + pszEnv = getenv("APPDATA"); + if (pszEnv) + strPath = pszEnv; } } - return pszPath; + return strPath; } #endif |