summaryrefslogtreecommitdiff
path: root/src/installationmanager.h
diff options
context:
space:
mode:
authorAl <26797547+Al12rs@users.noreply.github.com>2020-06-01 13:56:26 -0700
committerGitHub <noreply@github.com>2020-06-01 13:56:26 -0700
commit226b2b1843bbf41581757f44f8a2f4728f0a4b19 (patch)
treeef1daf7ea519dd2bc7c9ff4ccb64b5b3a734b50b /src/installationmanager.h
parenta92fdeb40064738df18d006285dfd05463d64223 (diff)
parent926267faa059082865fc3a1d62d3090645267e37 (diff)
Merge pull request #1098 from Holt59/install-manager-improvements
Installation manager improvements
Diffstat (limited to 'src/installationmanager.h')
-rw-r--r--src/installationmanager.h34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/installationmanager.h b/src/installationmanager.h
index 008a0916..cb355641 100644
--- a/src/installationmanager.h
+++ b/src/installationmanager.h
@@ -31,6 +31,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <archive.h>
#include <QProgressDialog>
#include <set>
+#include <map>
#include <errorcodes.h>
@@ -87,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
@@ -110,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.
@@ -153,6 +154,19 @@ public:
virtual QStringList extractFiles(std::vector<std::shared_ptr<const MOBase::FileTreeEntry>> 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<const MOBase::FileTreeEntry> entry) override;
+
+ /**
* @brief Installs the given archive.
*
* @param modName Suggested name of the mod.
@@ -186,7 +200,13 @@ private:
MOBase::IPluginInstaller::EInstallResult doInstall(MOBase::GuessedValue<QString> &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<const MOBase::IFileTree> fileTree);
bool ensureValidModName(MOBase::GuessedValue<QString> &name) const;
@@ -242,6 +262,10 @@ private:
QString m_CurrentFile;
QString m_ErrorMessage;
+ // Map from entries in the tree that is used by the installer and absolute
+ // paths to temporary files:
+ std::map<std::shared_ptr<const MOBase::FileTreeEntry>, QString> m_CreatedFiles;
+
QProgressDialog *m_InstallationProgress { nullptr };
int m_Progress;
QString m_ProgressFile;