Let's actually warn when a directory could not be removed.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21991 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2007-12-06 16:54:02 +00:00
parent 9faf680854
commit 5ae6e67a8b

View File

@ -292,7 +292,7 @@ unsigned long FileName::checksum() const
} }
// a directory may be passed here so we need to test it. (bug 3622) // a directory may be passed here so we need to test it. (bug 3622)
if (isDirectory()) { if (isDirectory()) {
LYXERR0('\\' << absFilename() << "\" is a directory!"); LYXERR0('"' << absFilename() << "\" is a directory!");
return 0; return 0;
} }
LYXERR0("Checksumming \"" << absFilename() << "\"."); LYXERR0("Checksumming \"" << absFilename() << "\".");
@ -304,8 +304,7 @@ bool FileName::removeFile() const
{ {
bool const success = QFile::remove(d->fi.absoluteFilePath()); bool const success = QFile::remove(d->fi.absoluteFilePath());
if (!success && exists()) if (!success && exists())
lyxerr << "FileName::removeFile(): Could not delete file " LYXERR0("Could not delete file " << *this);
<< *this << "." << endl;
return success; return success;
} }
@ -314,32 +313,32 @@ static bool rmdir(QFileInfo const & fi)
{ {
QDir dir(fi.absoluteFilePath()); QDir dir(fi.absoluteFilePath());
QFileInfoList list = dir.entryInfoList(); QFileInfoList list = dir.entryInfoList();
bool global_success = true; bool success = true;
for (int i = 0; i != list.size(); ++i) { for (int i = 0; i != list.size(); ++i) {
if (list.at(i).fileName() == ".") if (list.at(i).fileName() == ".")
continue; continue;
if (list.at(i).fileName() == "..") if (list.at(i).fileName() == "..")
continue; continue;
bool success; bool removed;
if (list.at(i).isDir()) { if (list.at(i).isDir()) {
LYXERR(Debug::FILES, "Erasing dir " LYXERR(Debug::FILES, "Removing dir "
<< fromqstr(list.at(i).absoluteFilePath())); << fromqstr(list.at(i).absoluteFilePath()));
success = rmdir(list.at(i)); removed = rmdir(list.at(i));
} }
else { else {
LYXERR(Debug::FILES, "Erasing file " LYXERR(Debug::FILES, "Removing file "
<< fromqstr(list.at(i).absoluteFilePath())); << fromqstr(list.at(i).absoluteFilePath()));
success = dir.remove(list.at(i).fileName()); removed = dir.remove(list.at(i).fileName());
} }
if (!success) { if (!removed) {
global_success = false; success = false;
lyxerr << "Could not delete " LYXERR0("Could not delete "
<< fromqstr(list.at(i).absoluteFilePath()) << "." << endl; << fromqstr(list.at(i).absoluteFilePath()));
} }
} }
QDir parent = fi.absolutePath(); QDir parent = fi.absolutePath();
global_success |= parent.rmdir(fi.fileName()); success &= parent.rmdir(fi.fileName());
return global_success; return success;
} }
@ -347,7 +346,7 @@ bool FileName::destroyDirectory() const
{ {
bool const success = rmdir(d->fi); bool const success = rmdir(d->fi);
if (!success) if (!success)
lyxerr << "Could not delete " << *this << "." << endl; LYXERR0("Could not delete " << *this);
return success; return success;
} }
@ -375,8 +374,7 @@ docstring FileName::displayName(int threshold) const
docstring FileName::fileContents(string const & encoding) const docstring FileName::fileContents(string const & encoding) const
{ {
if (!isReadableFile()) { if (!isReadableFile()) {
LYXERR0("File '" << *this LYXERR0("File '" << *this << "' is not redable!");
<< "' is not redable!");
return docstring(); return docstring();
} }
@ -457,8 +455,8 @@ string FileName::guessFormatFromContents() const
// GZIP \037\213 http://www.ietf.org/rfc/rfc1952.txt // GZIP \037\213 http://www.ietf.org/rfc/rfc1952.txt
// ZIP PK... http://www.halyava.ru/document/ind_arch.htm // ZIP PK... http://www.halyava.ru/document/ind_arch.htm
// Z \037\235 UNIX compress // Z \037\235 UNIX compress
// paranoia check
// paranoia check
if (empty() || !isReadableFile()) if (empty() || !isReadableFile())
return string(); return string();