summaryrefslogtreecommitdiffstats
path: root/heimdall-frontend/source/PackageData.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'heimdall-frontend/source/PackageData.cpp')
-rw-r--r--heimdall-frontend/source/PackageData.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/heimdall-frontend/source/PackageData.cpp b/heimdall-frontend/source/PackageData.cpp
index c3689b3..23ef720 100644
--- a/heimdall-frontend/source/PackageData.cpp
+++ b/heimdall-frontend/source/PackageData.cpp
@@ -30,37 +30,40 @@ PackageData::PackageData()
PackageData::~PackageData()
{
- for (int i = 0; i < files.length(); i++)
- delete files[i];
+ Clear(true);
}
-void PackageData::Clear(void)
+void PackageData::Clear(bool deletePackageDirectory)
{
- firmwareInfo.Clear();
-
- for (int i = 0; i < files.length(); i++)
- delete files[i];
+ if (deletePackageDirectory)
+ {
+ packageDirectory.removeRecursively();
+ }
- files.clear();
+ packageDirectory.setPath(QString());
+ firmwareInfo.Clear();
+ filePaths.clear();
}
-bool PackageData::ReadFirmwareInfo(QFile *file)
+bool PackageData::ReadFirmwareInfo(const QString& path)
{
- if (!file->open(QFile::ReadOnly))
+ QFile file(path);
+
+ if (!file.open(QFile::ReadOnly))
{
- Alerts::DisplayError(QString("Failed to open file: \1%s").arg(file->fileName()));
+ Alerts::DisplayError(QString("Failed to open file: %1").arg(path));
return (false);
}
- QXmlStreamReader xml(file);
+ QXmlStreamReader xml(&file);
bool success = firmwareInfo.ParseXml(xml);
- file->close();
-
return (success);
}
bool PackageData::IsCleared(void) const
{
- return (firmwareInfo.IsCleared() && files.isEmpty());
+ return (packageDirectory.path().length() == 0
+ && firmwareInfo.IsCleared()
+ && filePaths.isEmpty());
}