From e0c605be1d32b74b14da18cc7de4a66a4f6f3ecb Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Thu, 19 Dec 2019 18:42:17 -0500 Subject: initial implementation for updating file tree, buggy --- src/shared/directoryentry.cpp | 5 +++++ src/shared/directoryentry.h | 1 + src/shared/util.cpp | 27 +++++++++++++++++++++++++++ src/shared/util.h | 2 ++ 4 files changed, 35 insertions(+) (limited to 'src/shared') 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 . #include "util.h" #include "windows_error.h" #include "mainwindow.h" +#include "env.h" #include #include @@ -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( + 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 -- cgit v1.3.1