Implemented snapshot deletion function
This commit is contained in:
42
src/Insight/InsightWorker/Tasks/DeleteMemorySnapshot.cpp
Normal file
42
src/Insight/InsightWorker/Tasks/DeleteMemorySnapshot.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "DeleteMemorySnapshot.hpp"
|
||||
|
||||
#include <QFile>
|
||||
|
||||
#include "src/Services/PathService.hpp"
|
||||
#include "src/Helpers/EnumToStringMappings.hpp"
|
||||
#include "src/Logger/Logger.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
using Services::TargetControllerService;
|
||||
|
||||
DeleteMemorySnapshot::DeleteMemorySnapshot(
|
||||
const QString& snapshotId,
|
||||
Targets::TargetMemoryType memoryType
|
||||
)
|
||||
: snapshotId(snapshotId)
|
||||
, memoryType(memoryType)
|
||||
{}
|
||||
|
||||
void DeleteMemorySnapshot::run(TargetControllerService&) {
|
||||
using Targets::TargetMemorySize;
|
||||
|
||||
Logger::info("Deleting snapshot " + this->snapshotId.toStdString());
|
||||
|
||||
const auto snapshotFilePath = QString::fromStdString(Services::PathService::projectSettingsDirPath())
|
||||
+ "/memory_snapshots/" + EnumToStringMappings::targetMemoryTypes.at(this->memoryType) + "/"
|
||||
+ this->snapshotId + ".json";
|
||||
|
||||
auto snapshotFile = QFile(snapshotFilePath);
|
||||
|
||||
if (!snapshotFile.exists()) {
|
||||
Logger::warning(
|
||||
"Could not find snapshot file for " + this->snapshotId.toStdString() + " - expected path: "
|
||||
+ snapshotFilePath.toStdString()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
snapshotFile.remove();
|
||||
}
|
||||
}
|
||||
29
src/Insight/InsightWorker/Tasks/DeleteMemorySnapshot.hpp
Normal file
29
src/Insight/InsightWorker/Tasks/DeleteMemorySnapshot.hpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "InsightWorkerTask.hpp"
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
class DeleteMemorySnapshot: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DeleteMemorySnapshot(const QString& snapshotId, Targets::TargetMemoryType memoryType);
|
||||
|
||||
QString brief() const override {
|
||||
return "Deleting memory snapshot " + this->snapshotId;
|
||||
}
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
QString snapshotId;
|
||||
Targets::TargetMemoryType memoryType;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user