From 3f768ae53a580dbb41e8940bbf8b79336ead309c Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sat, 30 May 2020 15:00:10 +0200 Subject: Implement createFile() for the installation manager. --- src/installationmanager.h | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/installationmanager.h') diff --git a/src/installationmanager.h b/src/installationmanager.h index 008a0916..9eec4abc 100644 --- a/src/installationmanager.h +++ b/src/installationmanager.h @@ -31,6 +31,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include #include @@ -152,6 +153,19 @@ public: */ virtual QStringList extractFiles(std::vector> const& entries) override; + /** + * @brief Create a new file on the disk corresponding to the given entry. + * + * This method can be used by installer that needs to create files that are not in the original + * archive. At the end of the installation, if there are entries in the final tree that were used + * to create files, the corresponding files will be moved to the mod folder. + * + * @param entry The entry for which a temporary file should be created. + * + * @return the path to the created file. + */ + virtual QString createFile(std::shared_ptr entry) override; + /** * @brief Installs the given archive. * @@ -186,7 +200,13 @@ private: MOBase::IPluginInstaller::EInstallResult doInstall(MOBase::GuessedValue &modName, QString gameName, int modID, const QString &version, const QString &newestVersion, int categoryID, int fileCategoryID, const QString &repository); - //QString generateBackupName(const QString &directoryName) const; + /** + * @brief Clean the list of created files by removing all entries that are not + * in the given tree. + * + * @param tree The parent tree. Usually the tree returned by the installer. + */ + void cleanCreatedFiles(std::shared_ptr fileTree); bool ensureValidModName(MOBase::GuessedValue &name) const; @@ -242,6 +262,9 @@ private: QString m_CurrentFile; QString m_ErrorMessage; + // List of creates files: + std::map, QString> m_CreatedFiles; + QProgressDialog *m_InstallationProgress { nullptr }; int m_Progress; QString m_ProgressFile; -- cgit v1.3.1 From e9595ec91a91c00b1fda58305796591b510efdbf Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sat, 30 May 2020 17:49:46 +0200 Subject: Fix comment in installation manager. --- src/installationmanager.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/installationmanager.h') diff --git a/src/installationmanager.h b/src/installationmanager.h index 9eec4abc..bdc9eafc 100644 --- a/src/installationmanager.h +++ b/src/installationmanager.h @@ -262,7 +262,8 @@ private: QString m_CurrentFile; QString m_ErrorMessage; - // List of creates files: + // Map from entries in the tree that is used by the installer and absolute + // paths to temporary files: std::map, QString> m_CreatedFiles; QProgressDialog *m_InstallationProgress { nullptr }; -- cgit v1.3.1 From 1dc98e3af2f1c2296d4691c578e70d0ddeb810a1 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sat, 30 May 2020 21:32:04 +0200 Subject: Small update to installation manager following uibase changes. --- src/installationmanager.cpp | 10 +++------- src/installationmanager.h | 8 ++++---- 2 files changed, 7 insertions(+), 11 deletions(-) (limited to 'src/installationmanager.h') diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index b5efc5f6..66fd2e97 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -527,12 +527,12 @@ IPluginInstaller::EInstallResult InstallationManager::doInstall(GuessedValuegetLastError() == Archive::ERROR_EXTRACT_CANCELLED; } -bool InstallationManager::isRunning() +bool InstallationManager::isRunning() const { return m_IsRunning; } @@ -828,9 +828,5 @@ void InstallationManager::registerInstaller(IPluginInstaller *installer) QStringList InstallationManager::getSupportedExtensions() const { - QStringList result; - foreach (const QString &extension, m_SupportedExtensions) { - result.append(extension); - } - return result; + return QStringList(std::begin(m_SupportedExtensions), std::end(m_SupportedExtensions)); } diff --git a/src/installationmanager.h b/src/installationmanager.h index bdc9eafc..cb355641 100644 --- a/src/installationmanager.h +++ b/src/installationmanager.h @@ -88,12 +88,12 @@ public: /** * @return true if the installation was canceled **/ - bool wasCancelled(); + bool wasCancelled() const; /** * @return true if an installation is currently in progress **/ - bool isRunning(); + bool isRunning() const; /** * @brief retrieve a string describing the specified error code @@ -111,9 +111,9 @@ public: void registerInstaller(MOBase::IPluginInstaller *installer); /** - * @return list of file extensions we can install + * @return the extensions of archives supported by this installation manager. */ - QStringList getSupportedExtensions() const; + QStringList getSupportedExtensions() const override; /** * @brief Extract the specified file from the currently opened archive to a temporary location. -- cgit v1.3.1