summaryrefslogtreecommitdiff
path: root/src/envmodule.h
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-07-18 23:13:57 -0400
committerisanae <14251494+isanae@users.noreply.github.com>2019-07-22 07:33:38 -0400
commitb2a1e1391fdd6bdee1c5e8d337b273447c70a506 (patch)
treebbcee13a329fd9276a43a2d524f48ff83c32517b /src/envmodule.h
parentf95479b981b41f51a3ecf055c73f42440766e5d7 (diff)
split env
Diffstat (limited to 'src/envmodule.h')
-rw-r--r--src/envmodule.h98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/envmodule.h b/src/envmodule.h
new file mode 100644
index 00000000..ea1156bd
--- /dev/null
+++ b/src/envmodule.h
@@ -0,0 +1,98 @@
+#include <QString>
+#include <QDateTime>
+
+namespace env
+{
+
+// represents one module
+//
+class Module
+{
+public:
+ explicit Module(QString path, std::size_t fileSize);
+
+ // returns the module's path
+ //
+ const QString& path() const;
+
+ // returns the module's path in lowercase and using forward slashes
+ //
+ QString displayPath() const;
+
+ // returns the size in bytes, may be 0
+ //
+ std::size_t fileSize() const;
+
+ // returns the x.x.x.x version embedded from the version info, may be empty
+ //
+ const QString& version() const;
+
+ // returns the FileVersion entry from the resource file, returns
+ // "(no version)" if not available
+ //
+ const QString& versionString() const;
+
+ // returns the build date from the version info, or the creation time of the
+ // file on the filesystem, may be empty
+ //
+ const QDateTime& timestamp() const;
+
+ // returns the md5 of the file, may be empty for system files
+ //
+ const QString& md5() const;
+
+ // converts timestamp() to a string for display, returns "(no timestamp)" if
+ // not available
+ //
+ QString timestampString() const;
+
+ // returns a string with all the above information on one line
+ //
+ QString toString() const;
+
+private:
+ // contains the information from the version resource
+ //
+ struct FileInfo
+ {
+ VS_FIXEDFILEINFO ffi;
+ QString fileDescription;
+ };
+
+ QString m_path;
+ std::size_t m_fileSize;
+ QString m_version;
+ QDateTime m_timestamp;
+ QString m_versionString;
+ QString m_md5;
+
+ // returns information from the version resource
+ //
+ FileInfo getFileInfo() const;
+
+ // uses VS_FIXEDFILEINFO to build the version string
+ //
+ QString getVersion(const VS_FIXEDFILEINFO& fi) const;
+
+ // uses the file date from VS_FIXEDFILEINFO if available, or gets the
+ // creation date on the file
+ //
+ QDateTime getTimestamp(const VS_FIXEDFILEINFO& fi) const;
+
+ // returns the md5 hash unless the path contains "\windows\"
+ //
+ QString getMD5() const;
+
+ // gets VS_FIXEDFILEINFO from the file version info buffer
+ //
+ VS_FIXEDFILEINFO getFixedFileInfo(std::byte* buffer) const;
+
+ // gets FileVersion from the file version info buffer
+ //
+ QString getFileDescription(std::byte* buffer) const;
+};
+
+
+std::vector<Module> getLoadedModules();
+
+} // namespace env