Commit d2811dfd authored by Dennis Rassmann's avatar Dennis Rassmann

flasher: add "delete directories recursive"-function

Signed-off-by: Dennis Rassmann's avatarshowp1984 <showp1984@gmail.com>
parent ddada14e
......@@ -220,8 +220,33 @@ bool flasher::extract_zip(const QString & filePath, const QString & extDirPath,
return true;
}
bool flasher::rmdir_recursive(const QString &dirName)
{
bool result = true;
QDir dir(dirName);
if (dir.exists(dirName)) {
Q_FOREACH(QFileInfo info, dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst)) {
if (info.isDir()) {
result = rmdir_recursive(info.absoluteFilePath());
}
else {
result = QFile::remove(info.absoluteFilePath());
}
if (!result) {
return result;
}
}
result = dir.rmdir(dirName);
}
return result;
}
void flasher::flash_device(void)
{
bool ret;
if (firstcall) {
firstcall = false;
} else {
......@@ -279,6 +304,12 @@ void flasher::flash_device(void)
ui->bar_flash->setValue(80);
break;
case RELEASE_CONTROLS:
ret = rmdir_recursive(QString(qApp->applicationDirPath() + "/" + tmp_folder));
if (!ret) {
ui->txt_out->append("Error! Could not delete temporary directory: " + tmp_folder);
} else {
ui->txt_out->append("Deleted temporary directory: " + tmp_folder);
}
ui->bar_flash->setValue(90);
flashtimer->stop();
ui->btn_quit->setEnabled(true);
......@@ -313,8 +344,6 @@ int flasher::extract(void)
ui->txt_out->append("Successfully extracted zip file.");
}
ui->bar_extract->hide();
//QDir().rmdir(tmp_folder);
//ui->txt_out->append("Deleted temporary directory: " + tmp_folder);
//skip to detect
return DETECT;
}
......
......@@ -71,6 +71,7 @@ private slots:
int get_booted(void);
int push_files(void);
bool extract_zip(const QString&, const QString&, const QString&);
bool rmdir_recursive(const QString&);
};
#endif // FLASHER_H
/****************************************************************************
** Meta object code from reading C++ file 'detect.h'
**
** Created: Mon Jul 2 02:27:48 2012
** Created: Mon Jul 2 05:48:37 2012
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
**
** WARNING! All changes made in this file will be lost!
......
/****************************************************************************
** Meta object code from reading C++ file 'dragons.h'
**
** Created: Mon Jul 2 02:27:46 2012
** Created: Mon Jul 2 05:48:36 2012
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
**
** WARNING! All changes made in this file will be lost!
......
/****************************************************************************
** Meta object code from reading C++ file 'flasher.h'
**
** Created: Mon Jul 2 02:27:49 2012
** Created: Mon Jul 2 05:48:39 2012
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
**
** WARNING! All changes made in this file will be lost!
......@@ -23,7 +23,7 @@ static const uint qt_meta_data_flasher[] = {
4, // revision
0, // classname
0, 0, // classinfo
11, 14, // methods
12, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
......@@ -42,6 +42,7 @@ static const uint qt_meta_data_flasher[] = {
176, 8, 146, 8, 0x08,
189, 8, 146, 8, 0x08,
210, 207, 202, 8, 0x08,
247, 8, 202, 8, 0x08,
0 // eod
};
......@@ -54,6 +55,7 @@ static const char qt_meta_stringdata_flasher[] = {
"int\0extract()\0detect_device()\0"
"get_booted()\0push_files()\0bool\0,,\0"
"extract_zip(QString,QString,QString)\0"
"rmdir_recursive(QString)\0"
};
const QMetaObject flasher::staticMetaObject = {
......@@ -101,9 +103,11 @@ int flasher::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; } break;
case 10: { bool _r = extract_zip((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])),(*reinterpret_cast< const QString(*)>(_a[3])));
if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break;
case 11: { bool _r = rmdir_recursive((*reinterpret_cast< const QString(*)>(_a[1])));
if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break;
default: ;
}
_id -= 11;
_id -= 12;
}
return _id;
}
......
/****************************************************************************
** Meta object code from reading C++ file 'mainwindow.h'
**
** Created: Mon Jul 2 02:27:45 2012
** Created: Mon Jul 2 05:48:34 2012
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
**
** WARNING! All changes made in this file will be lost!
......
/****************************************************************************
** Meta object code from reading C++ file 'openfile.h'
**
** Created: Mon Jul 2 02:27:51 2012
** Created: Mon Jul 2 05:48:40 2012
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
**
** WARNING! All changes made in this file will be lost!
......
/****************************************************************************
** Meta object code from reading C++ file 'quazipfile.h'
**
** Created: Mon Jul 2 01:49:02 2012
** Created: Mon Jul 2 05:23:23 2012
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
**
** WARNING! All changes made in this file will be lost!
......
/****************************************************************************
** Resource object code
**
** Created: Mon Jul 2 01:03:30 2012
** Created: Mon Jul 2 05:23:31 2012
** by: The Resource Compiler for Qt version 4.6.2
**
** WARNING! All changes made in this file will be lost!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment