From 9fb639a00e1a809a9ea9b5e68777ec46f534761c Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Sun, 24 May 2020 13:27:40 +0200 Subject: Update ModInfo to use a single file tree for all content-related operations. --- src/modinfowithconflictinfo.h | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'src/modinfowithconflictinfo.h') diff --git a/src/modinfowithconflictinfo.h b/src/modinfowithconflictinfo.h index 94a61c62..5bc1d585 100644 --- a/src/modinfowithconflictinfo.h +++ b/src/modinfowithconflictinfo.h @@ -1,6 +1,8 @@ #ifndef MODINFOWITHCONFLICTINFO_H #define MODINFOWITHCONFLICTINFO_H +#include + #include "modinfo.h" #include @@ -13,6 +15,11 @@ public: std::vector getConflictFlags() const override; virtual std::vector getFlags() const override; + /** + * @return true if this mod is considered "valid", that is: it contains data used by the game + **/ + virtual bool isValid() const override; + /** * @brief clear all caches held for this mod */ @@ -32,6 +39,13 @@ public: virtual void doConflictCheck() const override; +public slots: + + /** + * @brief Notify this mod that the content of the disk may have changed. + */ + virtual void diskContentModified(); + protected: /** @@ -41,6 +55,17 @@ protected: **/ virtual bool doTestValid() const; + /** + * @brief Retrieve a file tree corresponding to the underlying disk content + * of this mod. + * + * The file tree should not be cached since it is already cached and updated when + * required. + * + * @return a file tree representing the content of this mod. + */ + std::shared_ptr contentFileTree() const; + ModInfoWithConflictInfo( PluginContainer* pluginContainer, const MOBase::IPluginGame* gamePlugin, @@ -81,10 +106,19 @@ private: bool hasHiddenFiles() const; -private: +protected: // Current game plugin running in MO2: - MOBase::IPluginGame const* m_GamePlugin; + MOBase::IPluginGame const * const m_GamePlugin; + +private: + + // Mutex: + mutable std::mutex m_Mutex; + + // File tree representing the content of the disk. A null pointer indicates + // that the content needs to be loaded from the disk: + mutable std::shared_ptr m_FileTree = nullptr; MOShared::DirectoryEntry **m_DirectoryStructure; -- cgit v1.3.1