feat(cpn): Clean up B&W MODELS folder before write to radio (#1932)

This commit is contained in:
Neil Horne
2022-05-04 18:48:11 +10:00
committed by GitHub
parent 87021209b3
commit 9d6d91d99c
6 changed files with 57 additions and 16 deletions
+14 -1
View File
@@ -61,7 +61,7 @@ bool SdcardFormat::getFileList(std::list<std::string>& filelist)
{
QDir dir(filename);
if (!dir.cd("MODELS")) return false;
QStringList ql = dir.entryList();
for (const auto& str : ql) {
filelist.push_back("MODELS/" + str.toStdString());
@@ -69,6 +69,19 @@ bool SdcardFormat::getFileList(std::list<std::string>& filelist)
return true;
}
bool SdcardFormat::deleteFile(const QString & filename)
{
QString path = this->filename + "/" + filename;
if (!QFile::remove(path)) {
setError(tr("Error deleting file %1").arg(path));
return false;
}
qDebug() << "File" << path << "deleted";
return true;
}
bool SdcardStorageFactory::probe(const QString & path)
{
return QDir(path).exists();