summaryrefslogtreecommitdiff
path: root/src/env.cpp
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2020-12-24 23:06:53 -0500
committerGitHub <noreply@github.com>2020-12-24 23:06:53 -0500
commit89bbdf22cde8d16d2d5e72999abf97b38ecd7b11 (patch)
tree3f4c4de743acdbb90e7e9997147f478c0c1f698e /src/env.cpp
parent06ca11edfb2957d07f9e7bccce1e8a765b1d0209 (diff)
parent9441d49c6d7dff23395460076112b57d4c0e8743 (diff)
Merge pull request #1328 from isanae/stuff
Stuff
Diffstat (limited to 'src/env.cpp')
-rw-r--r--src/env.cpp39
1 files changed, 35 insertions, 4 deletions
diff --git a/src/env.cpp b/src/env.cpp
index 98d2e6ea..76473dfb 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>
@@ -344,7 +345,9 @@ void Environment::dump(const Settings& s) const
log::debug("modules loaded in process:");
for (const auto& m : loadedModules()) {
- log::debug(" . {}", m.toString());
+ if (m.interesting()) {
+ log::debug(" . {}", m.toString());
+ }
}
log::debug("displays:");
@@ -1009,7 +1012,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 +1048,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 +1065,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 +1144,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 +1170,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"