summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2020-12-24 10:02:56 -0500
committerisanae <14251494+isanae@users.noreply.github.com>2020-12-24 10:02:56 -0500
commitc8cff6166d05e77c843bb727702607f970d3d030 (patch)
tree53903e8bfec84ed78ed6e1753464cd6a43b628b4 /src
parent28d24b3caaf2d4fcee1441299bdf483939e7359f (diff)
added version to dmp filename
replaced QApplication calls so createVersionInfo() can be called without one, happens with dump_running_process.bat
Diffstat (limited to 'src')
-rw-r--r--src/env.cpp35
-rw-r--r--src/env.h4
-rw-r--r--src/shared/util.cpp5
3 files changed, 39 insertions, 5 deletions
diff --git a/src/env.cpp b/src/env.cpp
index 98d2e6ea..edd8cd6b 100644
--- a/src/env.cpp
+++ b/src/env.cpp
@@ -6,6 +6,7 @@
#include "envwindows.h"
#include "envdump.h"
#include "settings.h"
+#include "shared/util.h"
#include <log.h>
#include <utility.h>
@@ -1009,7 +1010,7 @@ bool registryValueExists(const QString& keyName, const QString& valueName)
// returns the filename of the given process or the current one
//
-std::wstring processFilename(HANDLE process=INVALID_HANDLE_VALUE)
+std::filesystem::path processPath(HANDLE process=INVALID_HANDLE_VALUE)
{
// double the buffer size 10 times
const int MaxTries = 10;
@@ -1045,7 +1046,7 @@ std::wstring processFilename(HANDLE process=INVALID_HANDLE_VALUE)
const std::wstring s(buffer.get(), writtenSize);
const std::filesystem::path path(s);
- return path.filename().native();
+ return path;
}
}
@@ -1062,6 +1063,21 @@ std::wstring processFilename(HANDLE process=INVALID_HANDLE_VALUE)
return {};
}
+std::wstring processFilename(HANDLE process=INVALID_HANDLE_VALUE)
+{
+ const auto p = processPath(process);
+ if (p.empty()) {
+ return {};
+ }
+
+ return p.filename().native();
+}
+
+std::filesystem::path thisProcessPath()
+{
+ return processPath();
+}
+
DWORD findOtherPid()
{
const std::wstring defaultName = L"ModOrganizer.exe";
@@ -1126,6 +1142,19 @@ std::wstring tempDir()
return std::wstring(buffer, buffer + written);
}
+std::wstring safeVersion()
+{
+ try
+ {
+ // this can throw
+ return MOShared::createVersionInfo().displayString(3).toStdWString() + L"-";
+ }
+ catch(...)
+ {
+ return {};
+ }
+}
+
HandlePtr tempFile(const std::wstring dir)
{
// maximum tries of incrementing the counter
@@ -1139,7 +1168,7 @@ HandlePtr tempFile(const std::wstring dir)
// i can go until MaxTries
std::wostringstream oss;
oss
- << L"ModOrganizer-"
+ << L"ModOrganizer-" << safeVersion()
<< std::setw(4) << (1900 + tm->tm_year)
<< std::setw(2) << std::setfill(L'0') << (tm->tm_mon + 1)
<< std::setw(2) << std::setfill(L'0') << tm->tm_mday << "T"
diff --git a/src/env.h b/src/env.h
index e9cb7a36..2152a40d 100644
--- a/src/env.h
+++ b/src/env.h
@@ -309,6 +309,10 @@ bool registryValueExists(const QString& key, const QString& value);
//
void deleteRegistryKeyIfEmpty(const QString& name);
+// returns the path to this process
+//
+std::filesystem::path thisProcessPath();
+
} // namespace env
#endif // ENV_ENV_H
diff --git a/src/shared/util.cpp b/src/shared/util.cpp
index f316549e..54c6b841 100644
--- a/src/shared/util.cpp
+++ b/src/shared/util.cpp
@@ -210,12 +210,13 @@ std::wstring GetFileVersionString(const std::wstring &fileName)
VersionInfo createVersionInfo()
{
- VS_FIXEDFILEINFO version = GetFileVersion(QApplication::applicationFilePath().toStdWString());
+ VS_FIXEDFILEINFO version = GetFileVersion(env::thisProcessPath().native());
if (version.dwFileFlags & VS_FF_PRERELEASE)
{
// Pre-release builds need annotating
- QString versionString = QString::fromStdWString(GetFileVersionString(QApplication::applicationFilePath().toStdWString()));
+ QString versionString = QString::fromStdWString(
+ GetFileVersionString(env::thisProcessPath().native()));
// The pre-release flag can be set without the string specifying what type of pre-release
bool noLetters = true;