Skip to content

Commit

Permalink
FileUtils::remove uses Qt5's new removeRecursively for dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
navzam committed Dec 26, 2013
1 parent c344f12 commit e87fe47
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/file_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,9 @@ bool kiss::FileUtils::remove(const QString &path)
QFileInfo fileInfo(path);
if(!fileInfo.exists()) return true;
if(fileInfo.isFile()) return QFile::remove(path);
if(!fileInfo.isDir()) return false;

QDir dir(path);
bool success = true;
foreach(const QFileInfo &entry, dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System
| QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst))
success &= remove(entry.absoluteFilePath());

return dir.rmdir(path) && success;
// TODO: Qt recommends not using this for user-visible directories... but we'll use it anyway
if(fileInfo.isDir()) return QDir(path).removeRecursively();
return false;
}

QString kiss::FileUtils::getExistingDirectory(QWidget *parent, const QString &caption, QFileDialog::Options options)
Expand Down

0 comments on commit e87fe47

Please sign in to comment.