summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2015-01-04 10:33:37 +0100
committerTannin <devnull@localhost>2015-01-04 10:33:37 +0100
commitb415db619ed027ec2acd283983624293274b090f (patch)
tree3b09112799f2728229ed98bca7b342f1e8d1232a /src/shared
parentbd8267993d1ed0292200f3052e3c30d4fc9c84f7 (diff)
parentb2d04d70fc6284797e1bf29f55a375cb59d012be (diff)
Merge
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/appconfig.inc1
-rw-r--r--src/shared/directoryentry.cpp56
-rw-r--r--src/shared/directoryentry.h10
-rw-r--r--src/shared/error_report.cpp12
-rw-r--r--src/shared/fallout3info.cpp12
-rw-r--r--src/shared/falloutnvinfo.cpp12
-rw-r--r--src/shared/gameinfo.cpp34
-rw-r--r--src/shared/gameinfo.h2
-rw-r--r--src/shared/inject.cpp16
-rw-r--r--src/shared/oblivioninfo.cpp14
-rw-r--r--src/shared/skyriminfo.cpp22
-rw-r--r--src/shared/util.cpp16
-rw-r--r--src/shared/windows_error.cpp4
13 files changed, 99 insertions, 112 deletions
diff --git a/src/shared/appconfig.inc b/src/shared/appconfig.inc
index 2ea4d627..4450763f 100644
--- a/src/shared/appconfig.inc
+++ b/src/shared/appconfig.inc
@@ -1,5 +1,6 @@
APPPARAM(std::wstring, translationPrefix, L"organizer")
APPPARAM(std::wstring, pluginPath, L"plugins")
+APPPARAM(std::wstring, profilesPath, L"profiles")
APPPARAM(std::wstring, modsPath, L"mods")
APPPARAM(std::wstring, downloadPath, L"downloads")
APPPARAM(std::wstring, overwritePath, L"overwrite")
diff --git a/src/shared/directoryentry.cpp b/src/shared/directoryentry.cpp
index 7c0e7119..7f7a01f5 100644
--- a/src/shared/directoryentry.cpp
+++ b/src/shared/directoryentry.cpp
@@ -232,8 +232,8 @@ std::vector<FileEntry::Ptr> FilesOrigin::getFiles() const
void FileEntry::addOrigin(int origin, FILETIME fileTime, const std::wstring &archive)
{
- m_LastAccessed = time(NULL);
- if (m_Parent != NULL) {
+ m_LastAccessed = time(nullptr);
+ if (m_Parent != nullptr) {
m_Parent->propagateOrigin(origin);
}
if (m_Origin == -1) {
@@ -290,8 +290,8 @@ bool FileEntry::removeOrigin(int origin)
// now we need to update the file time...
std::wstring filePath = getFullPath();
HANDLE file = ::CreateFile(filePath.c_str(), GENERIC_READ | GENERIC_WRITE,
- 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (!::GetFileTime(file, NULL, NULL, &m_FileTime)) {
+ 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
+ if (!::GetFileTime(file, nullptr, nullptr, &m_FileTime)) {
// maybe this file is in a bsa, but there is no easy way to find out which. User should refresh
// the view to find out
m_Archive = L"bsa?";
@@ -324,13 +324,13 @@ static bool ByOriginPriority(DirectoryEntry *entry, int LHS, int RHS)
FileEntry::FileEntry()
- : m_Index(UINT_MAX), m_Name(), m_Origin(-1), m_Parent(NULL), m_LastAccessed(time(NULL))
+ : m_Index(UINT_MAX), m_Name(), m_Origin(-1), m_Parent(nullptr), m_LastAccessed(time(nullptr))
{
LEAK_TRACE;
}
FileEntry::FileEntry(Index index, const std::wstring &name, DirectoryEntry *parent)
- : m_Index(index), m_Name(name), m_Origin(-1), m_Parent(parent), m_Archive(L""), m_LastAccessed(time(NULL))
+ : m_Index(index), m_Name(name), m_Origin(-1), m_Parent(parent), m_Archive(L""), m_LastAccessed(time(nullptr))
{
LEAK_TRACE;
}
@@ -351,7 +351,7 @@ void FileEntry::sortOrigins()
bool FileEntry::recurseParents(std::wstring &path, const DirectoryEntry *parent) const
{
- if (parent == NULL) {
+ if (parent == nullptr) {
return false;
} else {
// don't append the topmost parent because it is the virtual data-root
@@ -480,7 +480,7 @@ void DirectoryEntry::addFromBSA(const std::wstring &originName, std::wstring &di
void DirectoryEntry::propagateOrigin(int origin)
{
m_Origins.insert(origin);
- if (m_Parent != NULL) {
+ if (m_Parent != nullptr) {
m_Parent->propagateOrigin(origin);
}
}
@@ -515,13 +515,13 @@ void DirectoryEntry::addFiles(FilesOrigin &origin, wchar_t *buffer, int bufferOf
_snwprintf(buffer + bufferOffset, MAXPATH_UNICODE - bufferOffset, L"\\*");
- HANDLE searchHandle = NULL;
+ HANDLE searchHandle = nullptr;
if (SupportOptimizedFind()) {
- searchHandle = ::FindFirstFileExW(buffer, FindExInfoBasic, &findData, FindExSearchNameMatch, NULL,
+ searchHandle = ::FindFirstFileExW(buffer, FindExInfoBasic, &findData, FindExSearchNameMatch, nullptr,
FIND_FIRST_EX_LARGE_FETCH);
} else {
- searchHandle = ::FindFirstFileExW(buffer, FindExInfoStandard, &findData, FindExSearchNameMatch, NULL, 0);
+ searchHandle = ::FindFirstFileExW(buffer, FindExInfoStandard, &findData, FindExSearchNameMatch, nullptr, 0);
}
if (searchHandle != INVALID_HANDLE_VALUE) {
@@ -572,7 +572,7 @@ bool DirectoryEntry::removeFile(const std::wstring &filePath, int *origin)
std::wstring dirName = filePath.substr(0, pos);
std::wstring rest = filePath.substr(pos + 1);
DirectoryEntry *entry = getSubDirectoryRecursive(dirName, false);
- if (entry != NULL) {
+ if (entry != nullptr) {
return entry->removeFile(rest, origin);
} else {
return false;
@@ -610,7 +610,7 @@ void DirectoryEntry::removeDir(const std::wstring &path)
std::wstring dirName = path.substr(0, pos);
std::wstring rest = path.substr(pos + 1);
DirectoryEntry *entry = getSubDirectoryRecursive(dirName, false);
- if (entry != NULL) {
+ if (entry != nullptr) {
entry->removeDir(rest);
}
}
@@ -709,12 +709,12 @@ FilesOrigin &DirectoryEntry::getOriginByName(const std::wstring &name) const
int DirectoryEntry::getOrigin(const std::wstring &path, bool &archive)
{
- const DirectoryEntry *directory = NULL;
+ const DirectoryEntry *directory = nullptr;
const FileEntry::Ptr file = searchFile(path, &directory);
- if (file.get() != NULL) {
+ if (file.get() != nullptr) {
return file->getOrigin(archive);
} else {
- if (directory != NULL) {
+ if (directory != nullptr) {
return directory->anyOrigin();
} else {
return -1;
@@ -734,13 +734,13 @@ std::vector<FileEntry::Ptr> DirectoryEntry::getFiles() const
const FileEntry::Ptr DirectoryEntry::searchFile(const std::wstring &path, const DirectoryEntry **directory) const
{
- if (directory != NULL) {
- *directory = NULL;
+ if (directory != nullptr) {
+ *directory = nullptr;
}
if ((path.length() == 0) || (path == L"*")) {
// no file name -> the path ended on a (back-)slash
- if (directory != NULL) {
+ if (directory != nullptr) {
*directory = this;
}
return FileEntry::Ptr();
@@ -753,9 +753,9 @@ const FileEntry::Ptr DirectoryEntry::searchFile(const std::wstring &path, const
auto iter = m_Files.find(ToLower(path));
if (iter != m_Files.end()) {
return m_FileRegister->getFile(iter->second);
- } else if (directory != NULL) {
+ } else if (directory != nullptr) {
DirectoryEntry *temp = findSubDirectory(path);
- if (temp != NULL) {
+ if (temp != nullptr) {
*directory = temp;
}
}
@@ -763,7 +763,7 @@ const FileEntry::Ptr DirectoryEntry::searchFile(const std::wstring &path, const
// file is in in a subdirectory, recurse into the matching subdirectory
std::wstring pathComponent = path.substr(0, len);
DirectoryEntry *temp = findSubDirectory(pathComponent);
- if (temp != NULL) {
+ if (temp != nullptr) {
return temp->searchFile(path.substr(len + 1), directory);
}
}
@@ -778,7 +778,7 @@ DirectoryEntry *DirectoryEntry::findSubDirectory(const std::wstring &name) const
return *iter;
}
}
- return NULL;
+ return nullptr;
}
@@ -810,7 +810,7 @@ DirectoryEntry *DirectoryEntry::getSubDirectory(const std::wstring &name, bool c
new DirectoryEntry(name, this, originID, m_FileRegister, m_OriginConnection));
return *iter;
} else {
- return NULL;
+ return nullptr;
}
}
@@ -827,8 +827,8 @@ DirectoryEntry *DirectoryEntry::getSubDirectoryRecursive(const std::wstring &pat
return getSubDirectory(path, create);
} else {
DirectoryEntry *nextChild = getSubDirectory(path.substr(0, pos), create, originID);
- if (nextChild == NULL) {
- return NULL;
+ if (nextChild == nullptr) {
+ return nullptr;
} else {
return nextChild->getSubDirectoryRecursive(path.substr(pos + 1), create, originID);
}
@@ -890,7 +890,7 @@ void FileRegister::unregisterFile(FileEntry::Ptr file)
}
// unregister from directory
- if (file->getParent() != NULL) {
+ if (file->getParent() != nullptr) {
file->getParent()->removeFile(file->getIndex());
}
}
@@ -948,7 +948,7 @@ void FileRegister::removeOriginMulti(std::set<FileEntry::Index> indices, int ori
// only when disabling an origin that is probably frequently the case
std::set<DirectoryEntry*> parents;
BOOST_FOREACH (const FileEntry::Ptr &file, removedFiles) {
- if (file->getParent() != NULL) {
+ if (file->getParent() != nullptr) {
parents.insert(file->getParent());
}
}
diff --git a/src/shared/directoryentry.h b/src/shared/directoryentry.h
index c06a49a1..4333c1eb 100644
--- a/src/shared/directoryentry.h
+++ b/src/shared/directoryentry.h
@@ -250,12 +250,12 @@ public:
/** retrieve a file in this directory by name.
* @param name name of the file
- * @return fileentry object for the file or NULL if no file matches
+ * @return fileentry object for the file or nullptr if no file matches
*/
const FileEntry::Ptr findFile(const std::wstring &name) const;
/** search through this directory and all subdirectories for a file by the specified name (relative path).
- if directory is not NULL, the referenced variable will be set to the path containing the file */
+ if directory is not nullptr, the referenced variable will be set to the path containing the file */
const FileEntry::Ptr searchFile(const std::wstring &path, const DirectoryEntry **directory) const;
void insertFile(const std::wstring &filePath, FilesOrigin &origin, FILETIME fileTime);
@@ -263,7 +263,7 @@ public:
void removeFile(FileEntry::Index index);
// remove the specified file from the tree. This can be a path leading to a file in a subdirectory
- bool removeFile(const std::wstring &filePath, int *origin = NULL);
+ bool removeFile(const std::wstring &filePath, int *origin = nullptr);
/**
* @brief remove the specified directory
@@ -274,9 +274,9 @@ public:
bool remove(const std::wstring &fileName, int *origin) {
auto iter = m_Files.find(ToLower(fileName));
if (iter != m_Files.end()) {
- if (origin != NULL) {
+ if (origin != nullptr) {
FileEntry::Ptr entry = m_FileRegister->getFile(iter->second);
- if (entry.get() != NULL) {
+ if (entry.get() != nullptr) {
bool ignore;
*origin = entry->getOrigin(ignore);
}
diff --git a/src/shared/error_report.cpp b/src/shared/error_report.cpp
index 02ff2d56..c9277c1b 100644
--- a/src/shared/error_report.cpp
+++ b/src/shared/error_report.cpp
@@ -35,7 +35,7 @@ void reportError(LPCSTR format, ...)
vsnprintf(buffer, 1024, format, argList);
va_end(argList);
- MessageBoxA(NULL, buffer, "Error", MB_OK | MB_ICONERROR);
+ MessageBoxA(nullptr, buffer, "Error", MB_OK | MB_ICONERROR);
}
void reportError(LPCWSTR format, ...)
@@ -50,18 +50,18 @@ void reportError(LPCWSTR format, ...)
_vsnwprintf(buffer, 1024, format, argList);
va_end(argList);
- MessageBoxW(NULL, buffer, L"Error", MB_OK | MB_ICONERROR);
+ MessageBoxW(nullptr, buffer, L"Error", MB_OK | MB_ICONERROR);
}
std::string getCurrentErrorStringA()
{
- LPSTR buffer = NULL;
+ LPSTR buffer = nullptr;
DWORD errorCode = ::GetLastError();
if (FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buffer, 0, NULL) == 0) {
+ nullptr, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buffer, 0, nullptr) == 0) {
::SetLastError(errorCode);
return std::string();
} else {
@@ -78,12 +78,12 @@ std::string getCurrentErrorStringA()
std::wstring getCurrentErrorStringW()
{
- LPWSTR buffer = NULL;
+ LPWSTR buffer = nullptr;
DWORD errorCode = ::GetLastError();
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&buffer, 0, NULL) == 0) {
+ nullptr, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&buffer, 0, nullptr) == 0) {
::SetLastError(errorCode);
return std::wstring();
} else {
diff --git a/src/shared/fallout3info.cpp b/src/shared/fallout3info.cpp
index 82b285b7..6c420044 100644
--- a/src/shared/fallout3info.cpp
+++ b/src/shared/fallout3info.cpp
@@ -60,7 +60,7 @@ std::wstring Fallout3Info::getRegPathStatic()
WCHAR temp[MAX_PATH];
DWORD bufferSize = MAX_PATH;
- if (::RegQueryValueExW(key, L"Installed Path", NULL, NULL, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
+ if (::RegQueryValueExW(key, L"Installed Path", nullptr, nullptr, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
return std::wstring(temp);
} else {
return std::wstring();
@@ -74,9 +74,9 @@ std::wstring Fallout3Info::getInvalidationBSA()
bool Fallout3Info::isInvalidationBSA(const std::wstring &bsaName)
{
- static LPCWSTR invalidation[] = { L"Fallout - AI!.bsa", L"Fallout - Invalidation.bsa", NULL };
+ static LPCWSTR invalidation[] = { L"Fallout - AI!.bsa", L"Fallout - Invalidation.bsa", nullptr };
- for (int i = 0; invalidation[i] != NULL; ++i) {
+ for (int i = 0; invalidation[i] != nullptr; ++i) {
if (wcscmp(bsaName.c_str(), invalidation[i]) == 0) {
return true;
}
@@ -203,7 +203,7 @@ void Fallout3Info::createProfile(const std::wstring &directory, bool useDefaults
std::wostringstream source;
source << getLocalAppFolder() << "\\Fallout3\\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);
+ HANDLE file = ::CreateFileW(target.str().c_str(), GENERIC_WRITE, 0, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
::CloseHandle(file);
}
}
@@ -256,9 +256,9 @@ void Fallout3Info::repairProfile(const std::wstring &directory)
bool Fallout3Info::rerouteToProfile(const wchar_t *fileName, const wchar_t*)
{
- static LPCWSTR profileFiles[] = { L"fallout.ini", L"falloutprefs.ini", L"plugins.txt", NULL };
+ static LPCWSTR profileFiles[] = { L"fallout.ini", L"falloutprefs.ini", L"plugins.txt", nullptr };
- for (int i = 0; profileFiles[i] != NULL; ++i) {
+ for (int i = 0; profileFiles[i] != nullptr; ++i) {
if (_wcsicmp(fileName, profileFiles[i]) == 0) {
return true;
}
diff --git a/src/shared/falloutnvinfo.cpp b/src/shared/falloutnvinfo.cpp
index 178ce8b4..f589124a 100644
--- a/src/shared/falloutnvinfo.cpp
+++ b/src/shared/falloutnvinfo.cpp
@@ -61,7 +61,7 @@ std::wstring FalloutNVInfo::getRegPathStatic()
WCHAR temp[MAX_PATH];
DWORD bufferSize = MAX_PATH;
- if (::RegQueryValueExW(key, L"Installed Path", NULL, NULL, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
+ if (::RegQueryValueExW(key, L"Installed Path", nullptr, nullptr, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
return std::wstring(temp);
} else {
return std::wstring();
@@ -75,9 +75,9 @@ std::wstring FalloutNVInfo::getInvalidationBSA()
bool FalloutNVInfo::isInvalidationBSA(const std::wstring &bsaName)
{
- static LPCWSTR invalidation[] = { L"Fallout - AI!.bsa", L"Fallout - Invalidation.bsa", NULL };
+ static LPCWSTR invalidation[] = { L"Fallout - AI!.bsa", L"Fallout - Invalidation.bsa", nullptr };
- for (int i = 0; invalidation[i] != NULL; ++i) {
+ for (int i = 0; invalidation[i] != nullptr; ++i) {
if (wcscmp(bsaName.c_str(), invalidation[i]) == 0) {
return true;
}
@@ -170,7 +170,7 @@ void FalloutNVInfo::createProfile(const std::wstring &directory, bool useDefault
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);
+ HANDLE file = ::CreateFileW(target.c_str(), GENERIC_WRITE, 0, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
::CloseHandle(file);
}
}
@@ -247,9 +247,9 @@ void FalloutNVInfo::repairProfile(const std::wstring &directory)
bool FalloutNVInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t*)
{
- static LPCWSTR profileFiles[] = { L"fallout.ini", L"falloutprefs.ini", L"plugins.txt", NULL };
+ static LPCWSTR profileFiles[] = { L"fallout.ini", L"falloutprefs.ini", L"plugins.txt", nullptr };
- for (int i = 0; profileFiles[i] != NULL; ++i) {
+ for (int i = 0; profileFiles[i] != nullptr; ++i) {
if (_wcsicmp(fileName, profileFiles[i]) == 0) {
return true;
}
diff --git a/src/shared/gameinfo.cpp b/src/shared/gameinfo.cpp
index 5439efff..3727ea49 100644
--- a/src/shared/gameinfo.cpp
+++ b/src/shared/gameinfo.cpp
@@ -27,17 +27,17 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "skyriminfo.h"
#include "util.h"
+#include <boost/assign.hpp>
+#include <boost/format.hpp>
#include <shlobj.h>
#include <sstream>
#include <cassert>
-#include <boost/assign.hpp>
-#include <boost/format.hpp>
namespace MOShared {
-GameInfo* GameInfo::s_Instance = NULL;
+GameInfo* GameInfo::s_Instance = nullptr;
GameInfo::GameInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory)
@@ -49,7 +49,7 @@ GameInfo::GameInfo(const std::wstring &moDirectory, const std::wstring &moDataDi
void GameInfo::cleanup() {
delete GameInfo::s_Instance;
- GameInfo::s_Instance = NULL;
+ GameInfo::s_Instance = nullptr;
}
@@ -62,14 +62,14 @@ void GameInfo::identifyMyGamesDirectory(const std::wstring &file)
m_MyGamesDirectory.clear();
// a) this is the way it should work. get the configured My Documents\My Games directory
- if (::SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, myDocuments) == S_OK) {
+ if (::SHGetFolderPathW(nullptr, CSIDL_PERSONAL, nullptr, SHGFP_TYPE_CURRENT, myDocuments) == S_OK) {
m_MyGamesDirectory = std::wstring(myDocuments) + L"\\My Games";
}
// b) if there is no <game> directory there, look in the default directory
if (m_MyGamesDirectory.empty()
|| !FileExists(m_MyGamesDirectory + L"\\" + file)) {
- if (::SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_DEFAULT, myDocuments) == S_OK) {
+ if (::SHGetFolderPathW(nullptr, CSIDL_PERSONAL, nullptr, SHGFP_TYPE_DEFAULT, myDocuments) == S_OK) {
std::wstring fromDefault = std::wstring(myDocuments) + L"\\My Games";
if (FileExists(fromDefault + L"\\" + file)) {
m_MyGamesDirectory = fromDefault;
@@ -99,13 +99,13 @@ bool GameInfo::identifyGame(const std::wstring &moDirectory, const std::wstring
s_Instance = new SkyrimInfo(moDirectory, moDataDirectory, searchPath);
}
- return s_Instance != NULL;
+ return s_Instance != nullptr;
}
bool GameInfo::init(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gamePath)
{
- if (s_Instance == NULL) {
+ if (s_Instance == nullptr) {
if (gamePath.length() == 0) {
// search upward in the directory until a recognized game-binary is found
std::wstring searchPath(moDirectory);
@@ -126,7 +126,7 @@ bool GameInfo::init(const std::wstring &moDirectory, const std::wstring &moDataD
GameInfo &GameInfo::instance()
{
- assert(s_Instance != NULL);
+ assert(s_Instance != nullptr && "gameinfo not yet initialized");
return *s_Instance;
}
@@ -151,18 +151,6 @@ std::wstring GameInfo::getIniFilename() const
}
-std::wstring GameInfo::getDownloadDir() const
-{
- return m_OrganizerDirectory + L"\\downloads";
-}
-
-
-std::wstring GameInfo::getCacheDir() const
-{
- return m_OrganizerDirectory + L"\\webcache";
-}
-
-
std::wstring GameInfo::getOverwriteDir() const
{
return m_OrganizerDirectory + L"\\overwrite";
@@ -203,7 +191,7 @@ std::wstring GameInfo::getLocalAppFolder() const
wchar_t localAppFolder[MAX_PATH];
memset(localAppFolder, '\0', MAX_PATH * sizeof(wchar_t));
- if (::SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, localAppFolder) == S_OK) {
+ if (::SHGetFolderPathW(nullptr, CSIDL_LOCAL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, localAppFolder) == S_OK) {
return localAppFolder;
} else {
// fallback: try the registry
@@ -224,7 +212,7 @@ std::wstring GameInfo::getSpecialPath(LPCWSTR name) const
WCHAR temp[MAX_PATH];
DWORD bufferSize = MAX_PATH;
- errorcode = ::RegQueryValueExW(key, name, NULL, NULL, (LPBYTE)temp, &bufferSize);
+ errorcode = ::RegQueryValueExW(key, name, nullptr, nullptr, (LPBYTE)temp, &bufferSize);
if (errorcode != ERROR_SUCCESS) {
throw windows_error((boost::format("failed to look up special folder (%1%)") % ToString(name, true)).str(), errorcode);
}
diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h
index c11679f3..a9da0b97 100644
--- a/src/shared/gameinfo.h
+++ b/src/shared/gameinfo.h
@@ -109,8 +109,6 @@ public:
virtual std::wstring getProfilesDir() const;
virtual std::wstring getIniFilename() const;
- virtual std::wstring getDownloadDir() const;
- virtual std::wstring getCacheDir() const;
virtual std::wstring getOverwriteDir() const;
virtual std::wstring getLogDir() const;
virtual std::wstring getLootDir() const;
diff --git a/src/shared/inject.cpp b/src/shared/inject.cpp
index 5a111c4a..143652c2 100644
--- a/src/shared/inject.cpp
+++ b/src/shared/inject.cpp
@@ -57,13 +57,13 @@ void injectDLL(HANDLE processHandle, HANDLE threadHandle, const std::string &dll
_snprintf(parameters.initstr, 5, "Init"); //this is the name of thie initialisation function we want to call in the target process
HMODULE k32mod = ::LoadLibrary(__TEXT("kernel32.dll"));
- TLoadLibraryType loadLibraryFunc = NULL;
- TGetProcAddressType getProcAddressFunc = NULL;
+ TLoadLibraryType loadLibraryFunc = nullptr;
+ TGetProcAddressType getProcAddressFunc = nullptr;
// ansi binaries
- if (k32mod != NULL) {
+ if (k32mod != nullptr) {
loadLibraryFunc = reinterpret_cast<TLoadLibraryType>(::GetProcAddress(k32mod, "LoadLibraryA"));
getProcAddressFunc = reinterpret_cast<TGetProcAddressType>(::GetProcAddress(k32mod, "GetProcAddress"));
- if ((loadLibraryFunc == NULL) || (getProcAddressFunc == NULL)) {
+ if ((loadLibraryFunc == nullptr) || (getProcAddressFunc == nullptr)) {
throw windows_error("failed to determine address for required functions");
}
} else {
@@ -71,8 +71,8 @@ void injectDLL(HANDLE processHandle, HANDLE threadHandle, const std::string &dll
}
// allocate memory in the target process and write the parameter-block there
- LPVOID remoteMem = ::VirtualAllocEx(processHandle, NULL, sizeof(TParameters), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
- if (remoteMem == NULL) {
+ LPVOID remoteMem = ::VirtualAllocEx(processHandle, nullptr, sizeof(TParameters), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
+ if (remoteMem == nullptr) {
throw windows_error("failed to allocate memory in target process");
}
SIZE_T written;
@@ -104,8 +104,8 @@ void injectDLL(HANDLE processHandle, HANDLE threadHandle, const std::string &dll
};
// reserve memory for the stub
- PBYTE stubRemote = reinterpret_cast<PBYTE>(::VirtualAllocEx(processHandle, NULL, sizeof(stubLocal), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE));
- if (stubRemote == NULL) {
+ PBYTE stubRemote = reinterpret_cast<PBYTE>(::VirtualAllocEx(processHandle, nullptr, sizeof(stubLocal), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE));
+ if (stubRemote == nullptr) {
throw windows_error("failed to allocate memory for stub");
}
TParameters *remoteParams = reinterpret_cast<TParameters*>(remoteMem);
diff --git a/src/shared/oblivioninfo.cpp b/src/shared/oblivioninfo.cpp
index 89a795a5..586bcaef 100644
--- a/src/shared/oblivioninfo.cpp
+++ b/src/shared/oblivioninfo.cpp
@@ -61,7 +61,7 @@ std::wstring OblivionInfo::getRegPathStatic()
WCHAR temp[MAX_PATH];
DWORD bufferSize = MAX_PATH;
- if (::RegQueryValueExW(key, L"Installed Path", NULL, NULL, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
+ if (::RegQueryValueExW(key, L"Installed Path", nullptr, nullptr, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
return std::wstring(temp);
} else {
return std::wstring();
@@ -76,9 +76,9 @@ std::wstring OblivionInfo::getInvalidationBSA()
bool OblivionInfo::isInvalidationBSA(const std::wstring &bsaName)
{
static LPCWSTR invalidation[] = { L"Oblivion - Invalidation.bsa", L"ArchiveInvalidationInvalidated!.bsa",
- L"BSARedirection.bsa", NULL };
+ L"BSARedirection.bsa", nullptr };
- for (int i = 0; invalidation[i] != NULL; ++i) {
+ for (int i = 0; invalidation[i] != nullptr; ++i) {
if (wcscmp(bsaName.c_str(), invalidation[i]) == 0) {
return true;
}
@@ -158,7 +158,7 @@ void OblivionInfo::createProfile(const std::wstring &directory, bool useDefaults
std::wostringstream source;
source << getLocalAppFolder() << "\\Oblivion\\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);
+ HANDLE file = ::CreateFileW(target.str().c_str(), GENERIC_WRITE, 0, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
::CloseHandle(file);
}
}
@@ -194,7 +194,7 @@ void OblivionInfo::createProfile(const std::wstring &directory, bool useDefaults
if (!FileExists(target)) {
std::wstring source = getMyGamesDirectory() + L"\\Oblivion\\oblivionprefs.ini";
if (!::CopyFileW(source.c_str(), target.c_str(), true)) {
- if ((::CreateFileW(target.c_str(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL) == INVALID_HANDLE_VALUE) &&
+ if ((::CreateFileW(target.c_str(), GENERIC_WRITE, 0, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr) == INVALID_HANDLE_VALUE) &&
(::GetLastError() != ERROR_FILE_EXISTS)) {
throw windows_error(std::string("failed to create ini file: ") + ToString(target, false));
}
@@ -240,9 +240,9 @@ void OblivionInfo::repairProfile(const std::wstring &directory)
bool OblivionInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t*)
{
- static LPCWSTR profileFiles[] = { L"oblivion.ini", L"oblivionprefs.ini", L"plugins.txt", NULL };
+ static LPCWSTR profileFiles[] = { L"oblivion.ini", L"oblivionprefs.ini", L"plugins.txt", nullptr };
- for (int i = 0; profileFiles[i] != NULL; ++i) {
+ for (int i = 0; profileFiles[i] != nullptr; ++i) {
if (_wcsicmp(fileName, profileFiles[i]) == 0) {
return true;
}
diff --git a/src/shared/skyriminfo.cpp b/src/shared/skyriminfo.cpp
index 1203e3ed..1d00c4f3 100644
--- a/src/shared/skyriminfo.cpp
+++ b/src/shared/skyriminfo.cpp
@@ -39,7 +39,7 @@ SkyrimInfo::SkyrimInfo(const std::wstring &moDirectory, const std::wstring &moDa
identifyMyGamesDirectory(L"skyrim");
wchar_t appDataPath[MAX_PATH];
- if (SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appDataPath))) {
+ if (SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_LOCAL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, appDataPath))) {
m_AppData = appDataPath;
}
}
@@ -69,7 +69,7 @@ std::wstring SkyrimInfo::getRegPathStatic()
WCHAR temp[MAX_PATH];
DWORD bufferSize = MAX_PATH;
- if (::RegQueryValueExW(key, L"Installed Path", NULL, NULL, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
+ if (::RegQueryValueExW(key, L"Installed Path", nullptr, nullptr, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
return std::wstring(temp);
} else {
return std::wstring();
@@ -84,9 +84,9 @@ std::wstring SkyrimInfo::getInvalidationBSA()
bool SkyrimInfo::isInvalidationBSA(const std::wstring &bsaName)
{
- static LPCWSTR invalidation[] = { L"Skyrim - Invalidation.bsa", NULL };
+ static LPCWSTR invalidation[] = { L"Skyrim - Invalidation.bsa", nullptr };
- for (int i = 0; invalidation[i] != NULL; ++i) {
+ for (int i = 0; invalidation[i] != nullptr; ++i) {
if (wcscmp(bsaName.c_str(), invalidation[i]) == 0) {
return true;
}
@@ -229,7 +229,7 @@ void SkyrimInfo::createProfile(const std::wstring &directory, bool useDefaults)
std::wostringstream source;
source << getLocalAppFolder() << "\\Skyrim\\plugins.txt";
if (!::CopyFileW(source.str().c_str(), target.c_str(), true)) {
- HANDLE file = ::CreateFileW(target.c_str(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
+ HANDLE file = ::CreateFileW(target.c_str(), GENERIC_WRITE, 0, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
::CloseHandle(file);
}
}
@@ -237,7 +237,7 @@ void SkyrimInfo::createProfile(const std::wstring &directory, bool useDefaults)
if (!FileExists(target)) {
std::wstring source = getLocalAppFolder() + L"\\Skyrim\\loadorder.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);
+ HANDLE file = ::CreateFileW(target.c_str(), GENERIC_WRITE, 0, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
::CloseHandle(file);
}
}
@@ -259,7 +259,7 @@ void SkyrimInfo::createProfile(const std::wstring &directory, bool useDefaults)
}
if (!::CopyFileW(source.c_str(), target.c_str(), true)) {
if (::GetLastError() != ERROR_FILE_EXISTS) {
- throw windows_error(std::string("failed to copy ini file: ") + ToString(source, false));
+ throw windows_error(std::string("failed to copy ini file: ") + ToString(source, false) + " to " + ToString(target, false));
}
}
}
@@ -272,7 +272,7 @@ void SkyrimInfo::createProfile(const std::wstring &directory, bool useDefaults)
if (!::CopyFileW(source.c_str(), target.c_str(), true)) {
log("failed to copy ini file %ls", source.c_str());
// create empty
- if (::CreateFileW(target.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL) == INVALID_HANDLE_VALUE) {
+ if (::CreateFileW(target.c_str(), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr) == INVALID_HANDLE_VALUE) {
throw windows_error(std::string("failed to copy ini file: ") + ToString(source, false));
}
}
@@ -289,16 +289,16 @@ void SkyrimInfo::repairProfile(const std::wstring &directory)
bool SkyrimInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath)
{
- static LPCWSTR profileFiles[] = { L"skyrim.ini", L"skyrimprefs.ini", L"loadorder.txt", NULL };
+ static LPCWSTR profileFiles[] = { L"skyrim.ini", L"skyrimprefs.ini", L"loadorder.txt", nullptr };
- for (int i = 0; profileFiles[i] != NULL; ++i) {
+ for (int i = 0; profileFiles[i] != nullptr; ++i) {
if (_wcsicmp(fileName, profileFiles[i]) == 0) {
return true;
}
}
if ((_wcsicmp(fileName, L"plugins.txt") == 0) &&
- (m_AppData.empty() || (StrStrIW(fullPath, m_AppData.c_str()) != NULL))) {
+ (m_AppData.empty() || (StrStrIW(fullPath, m_AppData.c_str()) != nullptr))) {
return true;
}
diff --git a/src/shared/util.cpp b/src/shared/util.cpp
index d284b517..8f64277f 100644
--- a/src/shared/util.cpp
+++ b/src/shared/util.cpp
@@ -34,7 +34,7 @@ bool FileExists(const std::string &filename)
{
WIN32_FIND_DATAA findData;
ZeroMemory(&findData, sizeof(WIN32_FIND_DATAA));
- HANDLE search = ::FindFirstFileExA(filename.c_str(), FindExInfoStandard, &findData, FindExSearchNameMatch, NULL, 0);
+ HANDLE search = ::FindFirstFileExA(filename.c_str(), FindExInfoStandard, &findData, FindExSearchNameMatch, nullptr, 0);
if (search == INVALID_HANDLE_VALUE) {
return false;
} else {
@@ -47,7 +47,7 @@ bool FileExists(const std::wstring &filename)
{
WIN32_FIND_DATAW findData;
ZeroMemory(&findData, sizeof(WIN32_FIND_DATAW));
- HANDLE search = ::FindFirstFileExW(filename.c_str(), FindExInfoStandard, &findData, FindExSearchNameMatch, NULL, 0);
+ HANDLE search = ::FindFirstFileExW(filename.c_str(), FindExInfoStandard, &findData, FindExSearchNameMatch, nullptr, 0);
if (search == INVALID_HANDLE_VALUE) {
return false;
} else {
@@ -68,14 +68,14 @@ std::string ToString(const std::wstring &source, bool utf8)
std::string result;
if (source.length() > 0) {
UINT codepage = utf8 ? CP_UTF8 : GetACP();
- int sizeRequired = ::WideCharToMultiByte(codepage, 0, &source[0], -1, NULL, 0, NULL, NULL);
+ int sizeRequired = ::WideCharToMultiByte(codepage, 0, &source[0], -1, nullptr, 0, nullptr, nullptr);
if (sizeRequired == 0) {
throw windows_error("failed to convert string to multibyte");
}
// the size returned by WideCharToMultiByte contains zero termination IF -1 is specified for the length.
// we don't want that \0 in the string because then the length field would be wrong. Because madness
result.resize(sizeRequired - 1, '\0');
- ::WideCharToMultiByte(codepage, 0, &source[0], (int)source.size(), &result[0], sizeRequired, NULL, NULL);
+ ::WideCharToMultiByte(codepage, 0, &source[0], (int)source.size(), &result[0], sizeRequired, nullptr, nullptr);
}
return result;
@@ -86,7 +86,7 @@ std::wstring ToWString(const std::string &source, bool utf8)
std::wstring result;
if (source.length() > 0) {
UINT codepage = utf8 ? CP_UTF8 : GetACP();
- int sizeRequired = ::MultiByteToWideChar(codepage, 0, source.c_str(), source.length(), NULL, 0);
+ int sizeRequired = ::MultiByteToWideChar(codepage, 0, source.c_str(), source.length(), nullptr, 0);
if (sizeRequired == 0) {
throw windows_error("failed to convert string to wide character");
}
@@ -137,7 +137,7 @@ VS_FIXEDFILEINFO GetFileVersion(const std::wstring &fileName)
throw windows_error("failed to determine file version info");
}
- void *versionInfoPtr = NULL;
+ void *versionInfoPtr = nullptr;
UINT versionInfoLength = 0;
if (!::VerQueryValue(buffer, L"\\", &versionInfoPtr, &versionInfoLength)) {
throw windows_error("failed to determine file version");
@@ -166,14 +166,14 @@ std::string GetStack()
::SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS);
firstCall = false;
}
- if (!::SymInitialize(process, NULL, TRUE)) {
+ if (!::SymInitialize(process, nullptr, TRUE)) {
log("failed to initialize symbols: %d", ::GetLastError());
}
initialized.insert(::GetCurrentProcessId());
}
LPVOID stack[32];
- WORD frames = ::CaptureStackBackTrace(0, 100, stack, NULL);
+ WORD frames = ::CaptureStackBackTrace(0, 100, stack, nullptr);
char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)];
PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer;
diff --git a/src/shared/windows_error.cpp b/src/shared/windows_error.cpp
index 647a5bfb..97a58a20 100644
--- a/src/shared/windows_error.cpp
+++ b/src/shared/windows_error.cpp
@@ -27,13 +27,13 @@ std::string windows_error::constructMessage(const std::string& input, int inErro
std::ostringstream finalMessage;
finalMessage << input;
- LPSTR buffer = NULL;
+ LPSTR buffer = nullptr;
DWORD errorCode = inErrorCode != -1 ? inErrorCode : ::GetLastError();
// TODO: the message is not english?
if (FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buffer, 0, NULL) == 0) {
+ nullptr, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buffer, 0, nullptr) == 0) {
finalMessage << " (errorcode " << errorCode << ")";
} else {
LPSTR lastChar = buffer + strlen(buffer) - 2;