kdecore: use QFileInfo and QDir to check for existence instead of QFile where applicable

the paths checked in KMountPoint::Private::finalizePossibleMountPoint()
should be symlink to directory, not a file. the check in
KTempDir::removeDir() should obviously be for directory

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2020-01-13 02:54:32 +00:00
parent 8f0ce23410
commit b7a307d949
2 changed files with 4 additions and 4 deletions

View file

@ -23,7 +23,7 @@
#include <config.h>
#include <stdlib.h>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QTextStream>
#include "kstandarddirs.h"
@ -167,14 +167,14 @@ void KMountPoint::Private::finalizePossibleMountPoint(DetailsNeededFlags infoNee
if (mountedFrom.startsWith(QLatin1String("UUID="))) {
const QString uuid = mountedFrom.mid(5);
const QString potentialDevice = QFile::readLink(QString::fromLatin1("/dev/disk/by-uuid/") + uuid);
if (QFile::exists(potentialDevice)) {
if (QFileInfo(potentialDevice).exists()) {
mountedFrom = potentialDevice;
}
}
if (mountedFrom.startsWith(QLatin1String("LABEL="))) {
const QString label = mountedFrom.mid(6);
const QString potentialDevice = QFile::readLink(QString::fromLatin1("/dev/disk/by-label/") + label);
if (QFile::exists(potentialDevice)) {
if (QFileInfo(potentialDevice).exists()) {
mountedFrom = potentialDevice;
}
}

View file

@ -222,7 +222,7 @@ static bool rmtree(const QByteArray& name)
bool KTempDir::removeDir( const QString& path )
{
//kDebug(180) << path;
if ( !QFile::exists( path ) )
if ( !QDir( path ).exists() )
return true; // The goal is that there is no directory
const QByteArray cstr( QFile::encodeName( path ) );