use shared pointer
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com> use shared pointer
This commit is contained in:
parent
cadb7142f0
commit
79222a56e3
@ -451,7 +451,7 @@ void ExportToZipTask::executeTask()
|
|||||||
absolute = file.canonicalFilePath();
|
absolute = file.canonicalFilePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!JlCompress::compressFile(m_output, absolute, m_destinationPrefix + relative)) {
|
if (!JlCompress::compressFile(m_output.get(), absolute, m_destinationPrefix + relative)) {
|
||||||
emitFailed(tr("Could not read and compress %1").arg(relative));
|
emitFailed(tr("Could not read and compress %1").arg(relative));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include "minecraft/mod/Mod.h"
|
#include "minecraft/mod/Mod.h"
|
||||||
#include "tasks/Task.h"
|
#include "tasks/Task.h"
|
||||||
@ -145,39 +146,28 @@ bool collectFileListRecursively(const QString& rootDir, const QString& subDir, Q
|
|||||||
|
|
||||||
class ExportToZipTask : public Task {
|
class ExportToZipTask : public Task {
|
||||||
public:
|
public:
|
||||||
ExportToZipTask(QuaZip* output,
|
ExportToZipTask(std::shared_ptr<QuaZip> output,
|
||||||
QDir dir,
|
QDir dir,
|
||||||
QFileInfoList files,
|
QFileInfoList files,
|
||||||
QString destinationPrefix = "",
|
QString destinationPrefix = "",
|
||||||
bool followSymlinks = false,
|
bool followSymlinks = false)
|
||||||
bool cleanUp = false)
|
: m_output(output), m_dir(dir), m_files(files), m_destinationPrefix(destinationPrefix), m_followSymlinks(followSymlinks)
|
||||||
: m_output(output)
|
|
||||||
, m_dir(dir)
|
|
||||||
, m_files(files)
|
|
||||||
, m_destinationPrefix(destinationPrefix)
|
|
||||||
, m_followSymlinks(followSymlinks)
|
|
||||||
, m_cleanUp(cleanUp)
|
|
||||||
{
|
{
|
||||||
setAbortable(true);
|
setAbortable(true);
|
||||||
};
|
};
|
||||||
ExportToZipTask(QString outputPath, QString dir, QFileInfoList files, QString destinationPrefix = "", bool followSymlinks = false)
|
ExportToZipTask(QString outputPath, QString dir, QFileInfoList files, QString destinationPrefix = "", bool followSymlinks = false)
|
||||||
: ExportToZipTask(new QuaZip(outputPath), QDir(dir), files, destinationPrefix, followSymlinks, true){};
|
: ExportToZipTask(std::make_shared<QuaZip>(outputPath), QDir(dir), files, destinationPrefix, followSymlinks){};
|
||||||
|
|
||||||
virtual ~ExportToZipTask()
|
virtual ~ExportToZipTask() = default;
|
||||||
{
|
|
||||||
if (m_cleanUp)
|
|
||||||
delete m_output;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void executeTask() override;
|
virtual void executeTask() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QuaZip* m_output;
|
std::shared_ptr<QuaZip> m_output;
|
||||||
QDir m_dir;
|
QDir m_dir;
|
||||||
QFileInfoList m_files;
|
QFileInfoList m_files;
|
||||||
QString m_destinationPrefix;
|
QString m_destinationPrefix;
|
||||||
bool m_followSymlinks;
|
bool m_followSymlinks;
|
||||||
bool m_cleanUp;
|
|
||||||
};
|
};
|
||||||
} // namespace MMCZip
|
} // namespace MMCZip
|
||||||
|
Loading…
Reference in New Issue
Block a user