FileName::destroyDirectory(): Continue deleting even if if a delete operation failed.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21795 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-11-26 10:58:00 +00:00
parent d3f0a07af7
commit d918eac0d1

View File

@ -239,25 +239,32 @@ static bool rmdir(QFileInfo const & fi)
{
QDir dir(fi.absoluteFilePath());
QFileInfoList list = dir.entryInfoList();
bool global_success = true;
for (int i = 0; i < list.size(); ++i) {
if (list.at(i).fileName() == ".")
continue;
if (list.at(i).fileName() == "..")
continue;
bool success;
if (list.at(i).isDir()) {
LYXERR(Debug::FILES, "Erasing dir "
<< fromqstr(list.at(i).absoluteFilePath()) << endl);
if (!rmdir(list.at(i)))
return false;
success = rmdir(list.at(i));
}
else {
LYXERR(Debug::FILES, "Erasing file "
<< fromqstr(list.at(i).absoluteFilePath()) << endl);
dir.remove(list.at(i).fileName());
success = dir.remove(list.at(i).fileName());
}
if (!success) {
global_success = false;
lyxerr << "Could not delete "
<< fromqstr(list.at(i).absoluteFilePath()) << "." << endl;
}
}
QDir parent = fi.absolutePath();
return parent.rmdir(fi.fileName());
global_success |= parent.rmdir(fi.fileName());
return global_success;
}