diff options
author | Arno <arno@disconnect.de> | 2018-01-02 19:31:42 +0100 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2018-01-02 19:31:42 +0100 |
commit | c77061d4d19de23c805ccbcc7cc229b221d4c1d5 (patch) | |
tree | b947182bf298f61fbbf00d3cbca9a381ca870656 | |
parent | 2f0262b6e762ee4ecb6bf058493ab73a391bab4e (diff) | |
download | ShemovCleaner-c77061d4d19de23c805ccbcc7cc229b221d4c1d5.tar.gz ShemovCleaner-c77061d4d19de23c805ccbcc7cc229b221d4c1d5.tar.bz2 ShemovCleaner-c77061d4d19de23c805ccbcc7cc229b221d4c1d5.zip |
Try harder to delete a file
QFile::remove() fails when the read-only attribute is set. Turn out it
can be unset with QFile::setPermissions(QFile::ReadOther |
QFile::WriteOther). Try it when the initial call to remove() failed.
-rw-r--r-- | filewidget.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/filewidget.cpp b/filewidget.cpp index ac7f920..948a5d6 100644 --- a/filewidget.cpp +++ b/filewidget.cpp @@ -663,7 +663,11 @@ void FileWidget::deleteFiles(){ QDir d(fi.absoluteFilePath()); d.removeRecursively(); }else{ - QFile::remove(path); + if(!QFile::remove(path)){ + QFile f(path); + f.setPermissions(QFile::ReadOther | QFile::WriteOther); + f.remove(); + } } removed << idx.data().toString(); } |