summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-12-19 18:42:17 -0500
committerisanae <14251494+isanae@users.noreply.github.com>2020-02-04 03:33:18 -0500
commite0c605be1d32b74b14da18cc7de4a66a4f6f3ecb (patch)
treed35ab520b6e99bb3458f3a3c9d338766ee1a994f /src/shared
parent219bd59a21430f830136927564e18dfc25421927 (diff)
initial implementation for updating file tree, buggy
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/directoryentry.cpp5
-rw-r--r--src/shared/directoryentry.h1
-rw-r--r--src/shared/util.cpp27
-rw-r--r--src/shared/util.h2
4 files changed, 35 insertions, 0 deletions
diff --git a/src/shared/directoryentry.cpp b/src/shared/directoryentry.cpp
index 9d49ce1e..146662ad 100644
--- a/src/shared/directoryentry.cpp
+++ b/src/shared/directoryentry.cpp
@@ -885,6 +885,11 @@ const FileEntry::Ptr DirectoryEntry::findFile(const std::wstring &name) const
}
}
+bool DirectoryEntry::hasFile(const std::wstring& name) const
+{
+ return m_Files.contains(ToLower(name));
+}
+
DirectoryEntry *DirectoryEntry::getSubDirectory(const std::wstring &name, bool create, int originID)
{
for (DirectoryEntry *entry : m_SubDirectories) {
diff --git a/src/shared/directoryentry.h b/src/shared/directoryentry.h
index 0a857443..52265583 100644
--- a/src/shared/directoryentry.h
+++ b/src/shared/directoryentry.h
@@ -279,6 +279,7 @@ public:
* @return fileentry object for the file or nullptr if no file matches
*/
const FileEntry::Ptr findFile(const std::wstring &name) const;
+ bool hasFile(const std::wstring& name) const;
bool containsArchive(std::wstring archiveName);
diff --git a/src/shared/util.cpp b/src/shared/util.cpp
index baceddeb..302dea7d 100644
--- a/src/shared/util.cpp
+++ b/src/shared/util.cpp
@@ -20,6 +20,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "util.h"
#include "windows_error.h"
#include "mainwindow.h"
+#include "env.h"
#include <usvfs.h>
#include <usvfs_version.h>
@@ -290,6 +291,32 @@ QString getUsvfsVersionString()
}
}
+void SetThisThreadName(const QString& s)
+{
+ using SetThreadDescriptionType = HRESULT (
+ HANDLE hThread,
+ PCWSTR lpThreadDescription
+ );
+
+ static SetThreadDescriptionType* SetThreadDescription = [] {
+ SetThreadDescriptionType* p = nullptr;
+
+ env::LibraryPtr kernel32(LoadLibraryW(L"kernel32.dll"));
+ if (!kernel32) {
+ return p;
+ }
+
+ p = reinterpret_cast<SetThreadDescriptionType*>(
+ GetProcAddress(kernel32.get(), "SetThreadDescription"));
+
+ return p;
+ }();
+
+ if (SetThreadDescription) {
+ SetThreadDescription(GetCurrentThread(), s.toStdWString().c_str());
+ }
+}
+
} // namespace MOShared
diff --git a/src/shared/util.h b/src/shared/util.h
index e8a58549..b6f898db 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -47,6 +47,8 @@ bool CaseInsensitiveEqual(const std::wstring &lhs, const std::wstring &rhs);
MOBase::VersionInfo createVersionInfo();
QString getUsvfsVersionString();
+void SetThisThreadName(const QString& s);
+
} // namespace MOShared