Add optional delete from disk in collection and playlist

Fixes #284
This commit is contained in:
Jonas Kvinge
2020-08-19 22:02:35 +02:00
parent 9b14df6b27
commit 653a35496d
19 changed files with 411 additions and 87 deletions

View File

@@ -253,6 +253,30 @@ QString MakeTempDir(const QString template_name) {
}
bool MoveToTrashRecursive(const QString &path) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
QDir dir(path);
for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden)) {
if (!MoveToTrashRecursive(path + "/" + child))
return false;
}
for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden)) {
if (!QFile::moveToTrash(path + "/" + child))
return false;
}
return dir.rmdir(path);
#else
return false;
#endif
}
bool RemoveRecursive(const QString &path) {
QDir dir(path);