From 4d9795527d1b9fa77ceb0106f308a13f24e1fca4 Mon Sep 17 00:00:00 2001 From: Tannin Date: Sun, 11 Jan 2015 11:16:04 +0100 Subject: different way to check for file existence --- src/shared/util.cpp | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'src/shared/util.cpp') diff --git a/src/shared/util.cpp b/src/shared/util.cpp index d284b517..1cbf088b 100644 --- a/src/shared/util.cpp +++ b/src/shared/util.cpp @@ -32,28 +32,16 @@ namespace MOShared { 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); - if (search == INVALID_HANDLE_VALUE) { - return false; - } else { - FindClose(search); - return true; - } + DWORD dwAttrib = ::GetFileAttributesA(filename.c_str()); + + return (dwAttrib != INVALID_FILE_ATTRIBUTES); } 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); - if (search == INVALID_HANDLE_VALUE) { - return false; - } else { - FindClose(search); - return true; - } + DWORD dwAttrib = ::GetFileAttributesW(filename.c_str()); + + return (dwAttrib != INVALID_FILE_ATTRIBUTES); } bool FileExists(const std::wstring &searchPath, const std::wstring &filename) -- cgit v1.3.1 From 2400e2c99ed3aa44152147ea7402c7f05f984aec Mon Sep 17 00:00:00 2001 From: Tannin Date: Thu, 22 Jan 2015 19:44:38 +0100 Subject: cleanup (mostly removing unused includes) --- src/browserdialog.cpp | 1 + src/browserdialog.h | 3 +-- src/browserview.h | 1 - src/downloadlistsortproxy.cpp | 1 + src/downloadlistsortproxy.h | 4 +++- src/downloadlistwidget.cpp | 1 - src/downloadlistwidget.h | 3 +-- src/downloadlistwidgetcompact.cpp | 1 - src/downloadmanager.cpp | 6 ++++-- src/downloadmanager.h | 4 +++- src/executableslist.cpp | 4 ++-- src/installationmanager.cpp | 5 +++-- src/main.cpp | 12 +++++------ src/mainwindow.cpp | 9 ++++---- src/modinfo.cpp | 1 - src/modinfodialog.cpp | 3 ++- src/modinfodialog.h | 3 +-- src/modlistsortproxy.cpp | 1 - src/nexusinterface.cpp | 1 - src/nexusinterface.h | 3 +-- src/pluginlist.cpp | 6 +++--- src/pluginlistsortproxy.cpp | 1 - src/profilesdialog.cpp | 1 - src/qtgroupingproxy.cpp | 2 +- src/savegamegamebryo.cpp | 10 ++++----- src/savegameinfowidget.cpp | 1 + src/savegameinfowidget.h | 3 ++- src/savegameinfowidgetgamebryo.cpp | 1 + src/savegameinfowidgetgamebryo.h | 3 ++- src/selfupdater.cpp | 5 +++-- src/selfupdater.h | 3 ++- src/shared/directoryentry.cpp | 7 ++---- src/shared/directoryentry.h | 5 ----- src/shared/inject.cpp | 5 +---- src/shared/stackdata.cpp | 8 ++++--- src/shared/util.cpp | 44 -------------------------------------- src/shared/util.h | 6 ------ src/spawn.cpp | 6 +++--- src/transfersavesdialog.cpp | 1 + src/transfersavesdialog.h | 3 ++- 40 files changed, 68 insertions(+), 120 deletions(-) (limited to 'src/shared/util.cpp') diff --git a/src/browserdialog.cpp b/src/browserdialog.cpp index f93ffcae..6a76e600 100644 --- a/src/browserdialog.cpp +++ b/src/browserdialog.cpp @@ -19,6 +19,7 @@ along with Mod Organizer. If not, see . #include "browserdialog.h" #include "ui_browserdialog.h" +#include "browserview.h" #include "messagedialog.h" #include "report.h" diff --git a/src/browserdialog.h b/src/browserdialog.h index 10b44fac..e44234f0 100644 --- a/src/browserdialog.h +++ b/src/browserdialog.h @@ -20,8 +20,6 @@ along with Mod Organizer. If not, see . #ifndef BROWSERDIALOG_H #define BROWSERDIALOG_H -#include "browserview.h" -#include "tutorialcontrol.h" #include #include #include @@ -37,6 +35,7 @@ namespace Ui { class BrowserDialog; } +class BrowserView; /** * @brief a dialog containing a webbrowser that is intended to browse the nexus network diff --git a/src/browserview.h b/src/browserview.h index 4f002ffc..f8b132b8 100644 --- a/src/browserview.h +++ b/src/browserview.h @@ -20,7 +20,6 @@ along with Mod Organizer. If not, see . #ifndef NEXUSVIEW_H #define NEXUSVIEW_H -#include "finddialog.h" #include #include diff --git a/src/downloadlistsortproxy.cpp b/src/downloadlistsortproxy.cpp index 31deba0b..59d7bce6 100644 --- a/src/downloadlistsortproxy.cpp +++ b/src/downloadlistsortproxy.cpp @@ -19,6 +19,7 @@ along with Mod Organizer. If not, see . #include "downloadlistsortproxy.h" #include "downloadlist.h" +#include "downloadmanager.h" DownloadListSortProxy::DownloadListSortProxy(const DownloadManager *manager, QObject *parent) : QSortFilterProxyModel(parent), m_Manager(manager), m_CurrentFilter() diff --git a/src/downloadlistsortproxy.h b/src/downloadlistsortproxy.h index e2c1bfb6..71ac7e56 100644 --- a/src/downloadlistsortproxy.h +++ b/src/downloadlistsortproxy.h @@ -22,7 +22,9 @@ along with Mod Organizer. If not, see . #include -#include "downloadmanager.h" + + +class DownloadManager; class DownloadListSortProxy : public QSortFilterProxyModel diff --git a/src/downloadlistwidget.cpp b/src/downloadlistwidget.cpp index 9d276de9..a9f7aa12 100644 --- a/src/downloadlistwidget.cpp +++ b/src/downloadlistwidget.cpp @@ -19,7 +19,6 @@ along with Mod Organizer. If not, see . #include "downloadlistwidget.h" #include "ui_downloadlistwidget.h" -#include "downloadmanager.h" #include #include #include diff --git a/src/downloadlistwidget.h b/src/downloadlistwidget.h index a8e702e3..c1dfe4cd 100644 --- a/src/downloadlistwidget.h +++ b/src/downloadlistwidget.h @@ -20,14 +20,13 @@ along with Mod Organizer. If not, see . #ifndef DOWNLOADLISTWIDGET_H #define DOWNLOADLISTWIDGET_H +#include "downloadmanager.h" #include #include #include #include #include -#include "downloadmanager.h" - namespace Ui { class DownloadListWidget; } diff --git a/src/downloadlistwidgetcompact.cpp b/src/downloadlistwidgetcompact.cpp index 21a690ab..813b08bc 100644 --- a/src/downloadlistwidgetcompact.cpp +++ b/src/downloadlistwidgetcompact.cpp @@ -24,7 +24,6 @@ along with Mod Organizer. If not, see . #include #include #include -#include "downloadmanager.h" DownloadListWidgetCompact::DownloadListWidgetCompact(QWidget *parent) : diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index b803d170..1ccc5b67 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -20,6 +20,8 @@ along with Mod Organizer. If not, see . #include "downloadmanager.h" #include "report.h" #include "nxmurl.h" +#include "nexusinterface.h" +#include "nxmaccessmanager.h" #include #include #include @@ -1082,7 +1084,7 @@ QDateTime DownloadManager::matchDate(const QString &timeString) } -EFileCategory convertFileCategory(int id) +static EFileCategory convertFileCategory(int id) { // TODO: need to handle file categories in the mod page plugin switch (id) { @@ -1200,7 +1202,7 @@ void DownloadManager::nxmFileInfoAvailable(int modID, int fileID, QVariant userD m_RequestIDs.insert(m_NexusInterface->requestDownloadURL(modID, fileID, this, qVariantFromValue(test), QString())); } -int evaluateFileInfoMap(const QVariantMap &map, const std::map &preferredServers) +static int evaluateFileInfoMap(const QVariantMap &map, const std::map &preferredServers) { int result = 0; diff --git a/src/downloadmanager.h b/src/downloadmanager.h index 95288884..21987828 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -20,8 +20,8 @@ along with Mod Organizer. If not, see . #ifndef DOWNLOADMANAGER_H #define DOWNLOADMANAGER_H -#include "nexusinterface.h" #include +#include #include #include #include @@ -36,6 +36,8 @@ along with Mod Organizer. If not, see . #include +class NexusInterface; + /*! * \brief manages downloading of files and provides progress information for gui elements **/ diff --git a/src/executableslist.cpp b/src/executableslist.cpp index a526a9b7..f2bc02f6 100644 --- a/src/executableslist.cpp +++ b/src/executableslist.cpp @@ -29,14 +29,14 @@ using namespace MOBase; using namespace MOShared; -QDataStream &operator<<(QDataStream &out, const Executable &obj) +static QDataStream &operator<<(QDataStream &out, const Executable &obj) { out << obj.m_Title << obj.m_BinaryInfo.absoluteFilePath() << obj.m_Arguments << obj.m_CloseMO << obj.m_SteamAppID << obj.m_WorkingDirectory << obj.m_Custom << obj.m_Toolbar; return out; } -QDataStream &operator>>(QDataStream &in, Executable &obj) +static QDataStream &operator>>(QDataStream &in, Executable &obj) { QString binaryTemp; int closeStyleTemp; diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index 880587b7..eb788a9c 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -58,7 +58,8 @@ typedef Archive* (*CreateArchiveType)(); -template T resolveFunction(QLibrary &lib, const char *name) +template +static T resolveFunction(QLibrary &lib, const char *name) { T temp = reinterpret_cast(lib.resolve(name)); if (temp == NULL) { @@ -192,7 +193,7 @@ QString InstallationManager::extractFile(const QString &fileName) } -QString canonicalize(const QString &name) +static QString canonicalize(const QString &name) { QString result(name); if ((result.startsWith('/')) || diff --git a/src/main.cpp b/src/main.cpp index e0e91c40..51b4af82 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -81,7 +81,7 @@ using namespace MOShared; // set up required folders (for a first install or after an update or to fix a broken installation) -bool bootstrap() +static bool bootstrap() { GameInfo &gameInfo = GameInfo::instance(); @@ -153,7 +153,7 @@ bool bootstrap() } -void cleanupDir() +static void cleanupDir() { // files from previous versions of MO that are no longer // required (in that location) @@ -175,12 +175,12 @@ void cleanupDir() } -bool isNxmLink(const QString &link) +static bool isNxmLink(const QString &link) { return link.left(6).toLower() == "nxm://"; } -LONG WINAPI MyUnhandledExceptionFilter(struct _EXCEPTION_POINTERS *exceptionPtrs) +static LONG WINAPI MyUnhandledExceptionFilter(struct _EXCEPTION_POINTERS *exceptionPtrs) { typedef BOOL (WINAPI *FuncMiniDumpWriteDump)(HANDLE process, DWORD pid, HANDLE file, MINIDUMP_TYPE dumpType, const PMINIDUMP_EXCEPTION_INFORMATION exceptionParam, @@ -241,12 +241,12 @@ LONG WINAPI MyUnhandledExceptionFilter(struct _EXCEPTION_POINTERS *exceptionPtrs return result; } -void registerMetaTypes() +static void registerMetaTypes() { registerExecutable(); } -bool HaveWriteAccess(const std::wstring &path) +static bool HaveWriteAccess(const std::wstring &path) { bool writable = false; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6bb77a79..1ae165fb 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -61,6 +61,7 @@ along with Mod Organizer. If not, see . #include "aboutdialog.h" #include "safewritefile.h" #include "organizerproxy.h" +#include "nxmaccessmanager.h" #include #include #include @@ -1426,7 +1427,7 @@ HANDLE MainWindow::spawnBinaryDirect(const QFileInfo &binary, const QString &arg } } -std::wstring getProcessName(DWORD processId) +static std::wstring getProcessName(DWORD processId) { HANDLE process = ::OpenProcess(PROCESS_QUERY_INFORMATION, false, processId); @@ -1948,7 +1949,7 @@ static bool BySortValue(const std::pair &LHS, const st template -QStringList toStringList(InputIterator current, InputIterator end) +static QStringList toStringList(InputIterator current, InputIterator end) { QStringList result; for (; current != end; ++current) { @@ -2204,7 +2205,7 @@ void MainWindow::readSettings() } -bool renameFile(const QString &oldName, const QString &newName, bool overwrite = true) +static bool renameFile(const QString &oldName, const QString &newName, bool overwrite = true) { if (overwrite && QFile::exists(newName)) { QFile::remove(newName); @@ -3890,7 +3891,7 @@ void MainWindow::exportModListCSV() } } -void addMenuAsPushButton(QMenu *menu, QMenu *subMenu) +static void addMenuAsPushButton(QMenu *menu, QMenu *subMenu) { QPushButton *pushBtn = new QPushButton(subMenu->title()); pushBtn->setMenu(subMenu); diff --git a/src/modinfo.cpp b/src/modinfo.cpp index bf48ae8b..dd3f3c40 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -229,7 +229,6 @@ void ModInfo::updateIndices() { s_ModsByName.clear(); s_ModsByModID.clear(); - QRegExp backupRegEx(".*backup[0-9]*$"); for (unsigned int i = 0; i < s_Collection.size(); ++i) { QString modName = s_Collection[i]->name(); diff --git a/src/modinfodialog.cpp b/src/modinfodialog.cpp index e6fb6f10..d216a7d5 100644 --- a/src/modinfodialog.cpp +++ b/src/modinfodialog.cpp @@ -26,6 +26,7 @@ along with Mod Organizer. If not, see . #include "bbcode.h" #include "questionboxmemory.h" #include "settings.h" +#include "categories.h" #include #include @@ -54,7 +55,7 @@ private: }; -bool operator<(const ModFileListWidget &LHS, const ModFileListWidget &RHS) +static bool operator<(const ModFileListWidget &LHS, const ModFileListWidget &RHS) { return LHS.m_SortValue < RHS.m_SortValue; } diff --git a/src/modinfodialog.h b/src/modinfodialog.h index 652bcab6..312ff99e 100644 --- a/src/modinfodialog.h +++ b/src/modinfodialog.h @@ -22,7 +22,6 @@ along with Mod Organizer. If not, see . #include "modinfo.h" -#include "categories.h" #include "tutorabledialog.h" #include @@ -45,7 +44,7 @@ namespace Ui { class QFileSystemModel; class QTreeView; - +class CategoryFactory; /** * this is a larger dialog used to visualise information abount the mod. diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp index b0e33bf2..bef3c387 100644 --- a/src/modlistsortproxy.cpp +++ b/src/modlistsortproxy.cpp @@ -20,7 +20,6 @@ along with Mod Organizer. If not, see . #include "modlistsortproxy.h" #include "modinfo.h" #include "profile.h" -#include "modlist.h" #include "messagedialog.h" #include #include diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp index b4006097..490c7903 100644 --- a/src/nexusinterface.cpp +++ b/src/nexusinterface.cpp @@ -19,7 +19,6 @@ along with Mod Organizer. If not, see . #include "nexusinterface.h" #include "nxmaccessmanager.h" -#include "utility.h" #include "json.h" #include "selectiondialog.h" #include diff --git a/src/nexusinterface.h b/src/nexusinterface.h index af2f8c75..c645596e 100644 --- a/src/nexusinterface.h +++ b/src/nexusinterface.h @@ -21,7 +21,6 @@ along with Mod Organizer. If not, see . #define NEXUSINTERFACE_H -#include "nxmaccessmanager.h" #include #include @@ -37,7 +36,7 @@ along with Mod Organizer. If not, see . class NexusInterface; - +class NXMAccessManager; /** * @brief convenience class to make nxm requests easier diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index a97ad7af..cbfd9df2 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -52,11 +52,11 @@ using namespace MOBase; using namespace MOShared; -bool ByName(const PluginList::ESPInfo& LHS, const PluginList::ESPInfo& RHS) { +static bool ByName(const PluginList::ESPInfo& LHS, const PluginList::ESPInfo& RHS) { return LHS.m_Name.toUpper() < RHS.m_Name.toUpper(); } -bool ByPriority(const PluginList::ESPInfo& LHS, const PluginList::ESPInfo& RHS) { +static bool ByPriority(const PluginList::ESPInfo& LHS, const PluginList::ESPInfo& RHS) { if (LHS.m_IsMaster && !RHS.m_IsMaster) { return true; } else if (!LHS.m_IsMaster && RHS.m_IsMaster) { @@ -66,7 +66,7 @@ bool ByPriority(const PluginList::ESPInfo& LHS, const PluginList::ESPInfo& RHS) } } -bool ByDate(const PluginList::ESPInfo& LHS, const PluginList::ESPInfo& RHS) { +static bool ByDate(const PluginList::ESPInfo& LHS, const PluginList::ESPInfo& RHS) { return QFileInfo(LHS.m_FullPath).lastModified() < QFileInfo(RHS.m_FullPath).lastModified(); /* QString lhsExtension = LHS.m_Name.right(3).toLower(); QString rhsExtension = RHS.m_Name.right(3).toLower(); diff --git a/src/pluginlistsortproxy.cpp b/src/pluginlistsortproxy.cpp index aeb10d35..8d63e2e2 100644 --- a/src/pluginlistsortproxy.cpp +++ b/src/pluginlistsortproxy.cpp @@ -18,7 +18,6 @@ along with Mod Organizer. If not, see . */ #include "pluginlistsortproxy.h" -#include "pluginlist.h" #include "messagedialog.h" #include #include diff --git a/src/profilesdialog.cpp b/src/profilesdialog.cpp index 3fdad880..ef9b607b 100644 --- a/src/profilesdialog.cpp +++ b/src/profilesdialog.cpp @@ -19,7 +19,6 @@ along with Mod Organizer. If not, see . #include "profilesdialog.h" #include "ui_profilesdialog.h" -#include "profile.h" #include "report.h" #include "utility.h" #include "transfersavesdialog.h" diff --git a/src/qtgroupingproxy.cpp b/src/qtgroupingproxy.cpp index 64ca5241..c5ee8591 100644 --- a/src/qtgroupingproxy.cpp +++ b/src/qtgroupingproxy.cpp @@ -17,7 +17,7 @@ // Modifications 2013-03-27 to 2013-03-29 by Sebastian Herbord -#include "QtGroupingProxy.h" +#include "qtgroupingproxy.h" #include #include diff --git a/src/savegamegamebryo.cpp b/src/savegamegamebryo.cpp index f593ef5a..7b012e22 100644 --- a/src/savegamegamebryo.cpp +++ b/src/savegamegamebryo.cpp @@ -18,10 +18,10 @@ along with Mod Organizer. If not, see . */ #include "savegamegamebyro.h" +#include "gameinfo.h" #include #include #include -#include "gameinfo.h" #include #include #include @@ -31,7 +31,7 @@ using namespace MOShared; template -void FileRead(QFile &file, T &value) +static void FileRead(QFile &file, T &value) { int read = file.read(reinterpret_cast(&value), sizeof(T)); if (read != sizeof(T)) { @@ -41,7 +41,7 @@ void FileRead(QFile &file, T &value) template -void FileSkip(QFile &file, int count = 1) +static void FileSkip(QFile &file, int count = 1) { char ignore[sizeof(T)]; for (int i = 0; i < count; ++i) { @@ -52,7 +52,7 @@ void FileSkip(QFile &file, int count = 1) } -QString ReadBString(QFile &file) +static QString ReadBString(QFile &file) { char buffer[256]; file.read(buffer, 1); // size including zero termination @@ -62,7 +62,7 @@ QString ReadBString(QFile &file) } -QString ReadFOSString(QFile &file, bool delimiter) +static QString ReadFOSString(QFile &file, bool delimiter) { union { char lengthBuffer[2]; diff --git a/src/savegameinfowidget.cpp b/src/savegameinfowidget.cpp index 093b794c..ab48765a 100644 --- a/src/savegameinfowidget.cpp +++ b/src/savegameinfowidget.cpp @@ -20,6 +20,7 @@ along with Mod Organizer. If not, see . #include "savegameinfowidget.h" #include "ui_savegameinfowidget.h" #include "utility.h" +#include "savegame.h" #include diff --git a/src/savegameinfowidget.h b/src/savegameinfowidget.h index d1cd2b98..dfb0f8b1 100644 --- a/src/savegameinfowidget.h +++ b/src/savegameinfowidget.h @@ -22,12 +22,13 @@ along with Mod Organizer. If not, see . #include #include -#include "savegame.h" namespace Ui { class SaveGameInfoWidget; } +class SaveGame; + class SaveGameInfoWidget : public QWidget { Q_OBJECT diff --git a/src/savegameinfowidgetgamebryo.cpp b/src/savegameinfowidgetgamebryo.cpp index deaa3e01..e8f56982 100644 --- a/src/savegameinfowidgetgamebryo.cpp +++ b/src/savegameinfowidgetgamebryo.cpp @@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License along with Mod Organizer. If not, see . */ +#include "savegamegamebyro.h" #include "savegameinfowidgetgamebryo.h" #include #include diff --git a/src/savegameinfowidgetgamebryo.h b/src/savegameinfowidgetgamebryo.h index 1f5fd7ee..149a8885 100644 --- a/src/savegameinfowidgetgamebryo.h +++ b/src/savegameinfowidgetgamebryo.h @@ -21,11 +21,12 @@ along with Mod Organizer. If not, see . #define SAVEGAMEINFOWIDGETGAMEBRYO_H -#include "savegamegamebyro.h" #include "savegameinfowidget.h" #include "pluginlist.h" +class SaveGame; + class SaveGameInfoWidgetGamebryo : public SaveGameInfoWidget { public: diff --git a/src/selfupdater.cpp b/src/selfupdater.cpp index 6037422c..a97c2912 100644 --- a/src/selfupdater.cpp +++ b/src/selfupdater.cpp @@ -23,7 +23,8 @@ along with Mod Organizer. If not, see . #include "report.h" #include "messagedialog.h" #include "downloadmanager.h" - +#include "nexusinterface.h" +#include "nxmaccessmanager.h" #include #include #include @@ -45,7 +46,7 @@ using namespace MOShared; typedef Archive* (*CreateArchiveType)(); -template T resolveFunction(QLibrary &lib, const char *name) +template static T resolveFunction(QLibrary &lib, const char *name) { T temp = reinterpret_cast(lib.resolve(name)); if (temp == NULL) { diff --git a/src/selfupdater.h b/src/selfupdater.h index 75b0ff45..5877e1ec 100644 --- a/src/selfupdater.h +++ b/src/selfupdater.h @@ -21,7 +21,6 @@ along with Mod Organizer. If not, see . #define SELFUPDATER_H -#include "nexusinterface.h" #include #include @@ -31,6 +30,8 @@ along with Mod Organizer. If not, see . #include +class NexusInterface; + /** * @brief manages updates for Mod Organizer itself * This class is used to update the Mod Organizer diff --git a/src/shared/directoryentry.cpp b/src/shared/directoryentry.cpp index 7c0e7119..f34b0566 100644 --- a/src/shared/directoryentry.cpp +++ b/src/shared/directoryentry.cpp @@ -24,16 +24,13 @@ along with Mod Organizer. If not, see . #include #include #include -#include "error_report.h" -#include "util.h" #include "windows_error.h" #include #include #include -#include "util.h" #include "leaktrace.h" - #include +#include "error_report.h" namespace MOShared { @@ -155,7 +152,7 @@ void FilesOrigin::removeFile(FileEntry::Index index) -std::wstring tail(const std::wstring &source, const size_t count) +static std::wstring tail(const std::wstring &source, const size_t count) { if (count >= source.length()) { return source; diff --git a/src/shared/directoryentry.h b/src/shared/directoryentry.h index c06a49a1..7a39b576 100644 --- a/src/shared/directoryentry.h +++ b/src/shared/directoryentry.h @@ -36,11 +36,6 @@ along with Mod Organizer. If not, see . #include "util.h" - -#include "error_report.h" - - - namespace MOShared { diff --git a/src/shared/inject.cpp b/src/shared/inject.cpp index 5a111c4a..cf2a8972 100644 --- a/src/shared/inject.cpp +++ b/src/shared/inject.cpp @@ -93,7 +93,7 @@ void injectDLL(HANDLE processHandle, HANDLE threadHandle, const std::string &dll 0x68, 0xBA, 0xAD, 0xF0, 0x0D, // PUSH imm32 ("Init") 0x50, // PUSH EAX 0xB8, 0xBA, 0xAD, 0xF0, 0x0D, // MOVE EAX, imm32 (GetProcAddress) - 0xFF, 0xD0, // CALL EAX (GetProcAddress) + 0xFF, 0xD0, // CALL EAX (=GetProcAddress, leaves address of init function in eax) 0x68, 0xBA, 0xAD, 0xF0, 0x0D, // PUSH imm32 (profile name) 0x68, 0xBA, 0xAD, 0xF0, 0x0D, // PUSH imm32 (log level) 0xFF, 0xD0, // CALL EAX (=InitFunction) @@ -109,9 +109,6 @@ void injectDLL(HANDLE processHandle, HANDLE threadHandle, const std::string &dll throw windows_error("failed to allocate memory for stub"); } TParameters *remoteParams = reinterpret_cast(remoteMem); - // determine the remote addresses of each of the parameters -// ULONG remoteDLLName = reinterpret_cast(remoteMem); -// ULONG remoteInitString = remoteDLLName + MAX_PATH * sizeof(char); // dizzy yet? we still have to calculate the entry point as an address relative to our stub ULONG entryPoint = 0; diff --git a/src/shared/stackdata.cpp b/src/shared/stackdata.cpp index 7f6f6e52..016fb346 100644 --- a/src/shared/stackdata.cpp +++ b/src/shared/stackdata.cpp @@ -5,12 +5,14 @@ #include #include #include +#include "error_report.h" +#include using namespace MOShared; -void initDbgIfNecess() +static void initDbgIfNecess() { HANDLE process = ::GetCurrentProcess(); static std::set initialized; @@ -88,8 +90,7 @@ void StackData::load_modules(HANDLE process, DWORD processID) { CloseHandle(snap); } -#include "error_report.h" -#include +#pragma warning( disable : 4748 ) void StackData::initTrace() { load_modules(::GetCurrentProcess(), ::GetCurrentProcessId()); @@ -134,6 +135,7 @@ void StackData::initTrace() { } } +#pragma warning( enable : 4748 ) bool MOShared::operator==(const StackData &LHS, const StackData &RHS) { if (LHS.m_Count != RHS.m_Count) { diff --git a/src/shared/util.cpp b/src/shared/util.cpp index 1cbf088b..0f49d036 100644 --- a/src/shared/util.cpp +++ b/src/shared/util.cpp @@ -141,48 +141,4 @@ VS_FIXEDFILEINFO GetFileVersion(const std::wstring &fileName) } - - -std::string GetStack() -{ -#ifdef _DEBUG - HANDLE process = ::GetCurrentProcess(); - static std::set initialized; - if (initialized.find(::GetCurrentProcessId()) == initialized.end()) { - static bool firstCall = true; - if (firstCall) { - ::SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS); - firstCall = false; - } - if (!::SymInitialize(process, NULL, TRUE)) { - log("failed to initialize symbols: %d", ::GetLastError()); - } - initialized.insert(::GetCurrentProcessId()); - } - - LPVOID stack[32]; - WORD frames = ::CaptureStackBackTrace(0, 100, stack, NULL); - - char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)]; - PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer; - symbol->SizeOfStruct = sizeof(SYMBOL_INFO); - symbol->MaxNameLen = MAX_SYM_NAME; - - std::ostringstream stackStream; - for(unsigned int i = 0; i < frames; ++i) { - DWORD64 addr = (DWORD64)stack[i]; - DWORD64 displacement = 0; - if (!::SymFromAddr(::GetCurrentProcess(), addr, &displacement, symbol)) { - stackStream << frames - i - 1 << ": " << stack[i] << " - " << ::GetLastError() << " (error)\n"; - } else { - stackStream << frames - i - 1 << ": " << symbol->Name << "\n"; - } - } - return stackStream.str(); -#else - return ""; -#endif -} - - } // namespace MOShared diff --git a/src/shared/util.h b/src/shared/util.h index eba3fb3c..14017526 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -27,9 +27,6 @@ along with Mod Organizer. If not, see . namespace MOShared { - -static const int MAXPATH_UNICODE = 32767; - /// Test if a file (or directory) by the specified name exists bool FileExists(const std::string &filename); bool FileExists(const std::wstring &filename); @@ -47,9 +44,6 @@ std::wstring ToLower(const std::wstring &text); VS_FIXEDFILEINFO GetFileVersion(const std::wstring &fileName); -/// Get a stack trace as a line-break separated list of function names. This only works in debug builds -std::string GetStack(); - } // namespace MOShared #endif // UTIL_H diff --git a/src/spawn.cpp b/src/spawn.cpp index 08f8c9f0..f719578b 100644 --- a/src/spawn.cpp +++ b/src/spawn.cpp @@ -36,9 +36,9 @@ using namespace MOShared; static const int BUFSIZE = 4096; -bool spawn(LPCWSTR binary, LPCWSTR arguments, LPCWSTR currentDirectory, bool suspended, - HANDLE stdOut, HANDLE stdErr, - HANDLE& processHandle, HANDLE& threadHandle) +static bool spawn(LPCWSTR binary, LPCWSTR arguments, LPCWSTR currentDirectory, bool suspended, + HANDLE stdOut, HANDLE stdErr, + HANDLE& processHandle, HANDLE& threadHandle) { BOOL inheritHandles = FALSE; STARTUPINFO si; diff --git a/src/transfersavesdialog.cpp b/src/transfersavesdialog.cpp index b07b1673..e720fcd2 100644 --- a/src/transfersavesdialog.cpp +++ b/src/transfersavesdialog.cpp @@ -19,6 +19,7 @@ along with Mod Organizer. If not, see . #include "transfersavesdialog.h" #include "ui_transfersavesdialog.h" +#include "savegamegamebyro.h" #include "utility.h" #include #include diff --git a/src/transfersavesdialog.h b/src/transfersavesdialog.h index 37a85000..10048ed5 100644 --- a/src/transfersavesdialog.h +++ b/src/transfersavesdialog.h @@ -21,13 +21,14 @@ along with Mod Organizer. If not, see . #define TRANSFERSAVESDIALOG_H #include "tutorabledialog.h" -#include "savegamegamebyro.h" #include "profile.h" namespace Ui { class TransferSavesDialog; } +class SaveGame; + class TransferSavesDialog : public MOBase::TutorableDialog { Q_OBJECT -- cgit v1.3.1