diff options
| author | Thomas Tanner <trtanner@btinternet.com> | 2015-11-01 18:27:34 +0000 |
|---|---|---|
| committer | Thomas Tanner <trtanner@btinternet.com> | 2015-11-01 18:27:34 +0000 |
| commit | 184cff8a7731c83f049dedb0f8e20d91c36e77a3 (patch) | |
| tree | c20a2b3e0994ba613314d7ddce14aba08ffd9801 | |
| parent | dfdf80417e6b4a6b1a353810ba473aa70e0c9abd (diff) | |
Add support for version dependency checks
| -rw-r--r-- | SConstruct | 4 | ||||
| -rw-r--r-- | src/gameinfoimpl.cpp | 51 | ||||
| -rw-r--r-- | src/gameinfoimpl.h | 2 | ||||
| -rw-r--r-- | src/shared/fallout3info.h | 1 | ||||
| -rw-r--r-- | src/shared/falloutnvinfo.h | 1 | ||||
| -rw-r--r-- | src/shared/gameinfo.h | 1 | ||||
| -rw-r--r-- | src/shared/oblivioninfo.h | 1 | ||||
| -rw-r--r-- | src/shared/skyriminfo.h | 1 |
8 files changed, 57 insertions, 5 deletions
@@ -51,10 +51,6 @@ def setup_config_variables(): PathVariable('SEVENZIPPATH', 'Path to 7zip sources', sevenzippath, PathVariable.PathIsDir), PathVariable('ZLIBPATH', 'Path to zlib install', zlibpath, - PathVariable.PathIsDir). - PathVariable('ZLIBPATH', 'Path to zlib install', zlibpath, - PathVariable.PathIsDir), - PathVariable('ZLIBPATH', 'Path to zlib install', zlibpath, PathVariable.PathIsDir) ) diff --git a/src/gameinfoimpl.cpp b/src/gameinfoimpl.cpp index 025ce4e6..979e6c8d 100644 --- a/src/gameinfoimpl.cpp +++ b/src/gameinfoimpl.cpp @@ -18,8 +18,10 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. */
#include "gameinfoimpl.h"
-#include <gameinfo.h>
+#include "gameinfo.h"
#include <utility.h>
+
+#include <QDebug>
#include <QDir>
@@ -52,3 +54,50 @@ QString GameInfoImpl::binaryName() const {
return ToQString(GameInfo::instance().getBinaryName());
}
+
+namespace {
+
+QString GetAppVersion(std::wstring const &app_name)
+{
+ DWORD handle;
+ DWORD info_len = ::GetFileVersionInfoSizeW(app_name.c_str(), &handle);
+ if (info_len == 0) {
+ qDebug("GetFileVersionInfoSizeW Error %d", ::GetLastError());
+ throw std::runtime_error("Failed to get version info");
+ }
+
+ std::vector<char> buff(info_len);
+ if( ! ::GetFileVersionInfoW(app_name.c_str(), handle, info_len, buff.data())) {
+ qDebug("GetFileVersionInfoW Error %d", ::GetLastError());
+ throw std::runtime_error("Failed to get version info");
+ }
+
+ VS_FIXEDFILEINFO *pFileInfo;
+ UINT buf_len;
+ if ( ! ::VerQueryValueW(buff.data(), L"\\", reinterpret_cast<LPVOID *>(&pFileInfo), &buf_len)) {
+ qDebug("VerQueryValueW Error %d", ::GetLastError());
+ throw std::runtime_error("Failed to get version info");
+ }
+ return QString("%1.%2.%3.%4").arg(HIWORD(pFileInfo->dwFileVersionMS))
+ .arg(LOWORD(pFileInfo->dwFileVersionMS))
+ .arg(HIWORD(pFileInfo->dwFileVersionLS))
+ .arg(LOWORD(pFileInfo->dwFileVersionLS));
+}
+
+}
+
+QString GameInfoImpl::version() const
+{
+ std::wstring dir = GameInfo::instance().getGameDirectory();
+ std::wstring exec = GameInfo::instance().getBinaryName();
+ std::wstring target = L"\\\\?\\" + dir + L"\\" + exec;
+ return GetAppVersion(target.c_str());
+}
+
+QString GameInfoImpl::extenderVersion() const
+{
+ std::wstring dir = GameInfo::instance().getGameDirectory();
+ std::wstring exec = GameInfo::instance().getExtenderName();
+ std::wstring target = L"\\\\?\\" + dir + L"\\" + exec;
+ return GetAppVersion(target.c_str());
+}
diff --git a/src/gameinfoimpl.h b/src/gameinfoimpl.h index 3ed7be6b..b7ac78c5 100644 --- a/src/gameinfoimpl.h +++ b/src/gameinfoimpl.h @@ -33,6 +33,8 @@ public: virtual Type type() const;
virtual QString path() const;
virtual QString binaryName() const;
+ virtual QString version() const;
+ virtual QString extenderVersion() const;
};
diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h index 0045581d..62eb0a08 100644 --- a/src/shared/fallout3info.h +++ b/src/shared/fallout3info.h @@ -38,6 +38,7 @@ public: static std::wstring getRegPathStatic();
virtual std::wstring getRegPath() { return getRegPathStatic(); }
virtual std::wstring getBinaryName() { return L"Fallout3.exe"; }
+ virtual std::wstring getExtenderName() { return L"fose_loader.exe"; }
virtual GameInfo::Type getType() { return TYPE_FALLOUT3; }
diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h index e1a614d2..3039d8cc 100644 --- a/src/shared/falloutnvinfo.h +++ b/src/shared/falloutnvinfo.h @@ -38,6 +38,7 @@ public: static std::wstring getRegPathStatic();
virtual std::wstring getRegPath() { return getRegPathStatic(); }
virtual std::wstring getBinaryName() { return L"FalloutNV.exe"; }
+ virtual std::wstring getExtenderName() { return L"nvse_loader.exe"; }
virtual GameInfo::Type getType() { return TYPE_FALLOUTNV; }
diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h index a32b6b82..5b344932 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -60,6 +60,7 @@ public: virtual std::wstring getRegPath() = 0;
virtual std::wstring getBinaryName() = 0;
+ virtual std::wstring getExtenderName() = 0;
virtual GameInfo::Type getType() = 0;
diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h index 87ba26ff..02fa32c6 100644 --- a/src/shared/oblivioninfo.h +++ b/src/shared/oblivioninfo.h @@ -36,6 +36,7 @@ public: static std::wstring getRegPathStatic();
virtual std::wstring getRegPath() { return getRegPathStatic(); }
virtual std::wstring getBinaryName() { return L"Oblivion.exe"; }
+ virtual std::wstring getExtenderName() { return L"obse_loader.exe"; }
virtual GameInfo::Type getType() { return TYPE_OBLIVION; }
diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h index 5951f910..1824eb3e 100644 --- a/src/shared/skyriminfo.h +++ b/src/shared/skyriminfo.h @@ -38,6 +38,7 @@ public: static std::wstring getRegPathStatic();
virtual std::wstring getRegPath() { return getRegPathStatic(); }
virtual std::wstring getBinaryName() { return L"TESV.exe"; }
+ virtual std::wstring getExtenderName() { return L"skse_loader.exe"; }
virtual GameInfo::Type getType() { return TYPE_SKYRIM; }
|
