summaryrefslogtreecommitdiff
path: root/src/shared/falloutnvinfo.cpp
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2014-09-24 19:51:51 +0200
committerTannin <devnull@localhost>2014-09-24 19:51:51 +0200
commita62ecc5bf1e92e6dd2ba8e6e61a797641c254d92 (patch)
tree5e3538861b2768a1c16b3daf7f073e05b5764059 /src/shared/falloutnvinfo.cpp
parent5f1022917b655650f842dc8f34967716081685ef (diff)
- several style fixes suggested by static analysis
- will now support up to 4 levels of version numbers (major.minor.subminor.subsubminor
Diffstat (limited to 'src/shared/falloutnvinfo.cpp')
-rw-r--r--src/shared/falloutnvinfo.cpp58
1 files changed, 25 insertions, 33 deletions
diff --git a/src/shared/falloutnvinfo.cpp b/src/shared/falloutnvinfo.cpp
index 1715912d..ff441f13 100644
--- a/src/shared/falloutnvinfo.cpp
+++ b/src/shared/falloutnvinfo.cpp
@@ -55,15 +55,17 @@ std::wstring FalloutNVInfo::getRegPathStatic()
0, KEY_QUERY_VALUE, &key);
if (errorcode != ERROR_SUCCESS) {
- return L"";
+ return std::wstring();
}
WCHAR temp[MAX_PATH];
DWORD bufferSize = MAX_PATH;
- errorcode = ::RegQueryValueExW(key, L"Installed Path", NULL, NULL, (LPBYTE)temp, &bufferSize);
-
- return std::wstring(temp);
+ if (::RegQueryValueExW(key, L"Installed Path", NULL, NULL, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
+ return std::wstring(temp);
+ } else {
+ return std::wstring();
+ }
}
std::wstring FalloutNVInfo::getInvalidationBSA()
@@ -162,56 +164,46 @@ std::wstring FalloutNVInfo::getSteamAPPId(int) const
void FalloutNVInfo::createProfile(const std::wstring &directory, bool useDefaults)
{
- std::wostringstream target;
+ std::wstring target = directory + L"\\plugins.txt";
// copy plugins.txt
- target << directory << "\\plugins.txt";
-
- if (!FileExists(target.str())) {
- std::wostringstream source;
- source << getLocalAppFolder() << "\\FalloutNV\\plugins.txt";
- if (!::CopyFileW(source.str().c_str(), target.str().c_str(), true)) {
- HANDLE file = ::CreateFileW(target.str().c_str(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (!FileExists(target)) {
+ std::wstring source = getLocalAppFolder() + L"\\FalloutNV\\plugins.txt";
+ if (!::CopyFileW(source.c_str(), target.c_str(), true)) {
+ HANDLE file = ::CreateFileW(target.c_str(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
::CloseHandle(file);
}
}
// copy ini-file
- target.str(L""); target.clear();
- target << directory << L"\\fallout.ini";
+ target = directory + L"\\fallout.ini";
- if (!FileExists(target.str())) {
- std::wostringstream source;
+ if (!FileExists(target)) {
+ std::wstring source;
if (useDefaults) {
- source << getGameDirectory() << L"\\fallout_default.ini";
+ source = getGameDirectory() + L"\\fallout_default.ini";
} else {
- source << getMyGamesDirectory() << L"\\FalloutNV";
- if (FileExists(source.str(), L"fallout.ini")) {
- source << L"\\fallout.ini";
+ source = getMyGamesDirectory() + L"\\FalloutNV";
+ if (FileExists(source, L"fallout.ini")) {
+ source += L"\\fallout.ini";
} else {
- source.str(L"");
- source << getGameDirectory() << L"\\fallout_default.ini";
+ source = getGameDirectory() + L"\\fallout_default.ini";
}
}
- if (!::CopyFileW(source.str().c_str(), target.str().c_str(), true)) {
+ if (!::CopyFileW(source.c_str(), target.c_str(), true)) {
if (::GetLastError() != ERROR_FILE_EXISTS) {
- std::ostringstream stream;
- stream << "failed to copy ini file: " << ToString(source.str(), false);
- throw windows_error(stream.str());
+ throw windows_error("failed to copy ini file: " + ToString(source, false));
}
}
}
{ // copy falloutprefs.ini-file
- std::wstring target = directory.substr().append(L"\\falloutprefs.ini");
+ std::wstring target = directory + L"\\falloutprefs.ini";
if (!FileExists(target)) {
- std::wostringstream source;
- source << getMyGamesDirectory() << L"\\FalloutNV\\falloutprefs.ini";
- if (!::CopyFileW(source.str().c_str(), target.c_str(), true)) {
+ std::wstring source = getMyGamesDirectory() + L"\\FalloutNV\\falloutprefs.ini";
+ if (!::CopyFileW(source.c_str(), target.c_str(), true)) {
if (::GetLastError() != ERROR_FILE_EXISTS) {
- std::ostringstream stream;
- stream << "failed to copy ini file: " << ToString(source.str(), false);
- throw windows_error(stream.str());
+ throw windows_error("failed to copy ini file: " + ToString(source, false));
}
}
}