mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kdecore: simplify KStandardDirs::exists()
also, added a debug message to tell when and on what this method is called. I'm seeing many obscure check done repeatedly, especially MIME paths check done over and over again when opening a folder with dolphin so that should help identify places where optimizations should be made.
This commit is contained in:
parent
79d3e27b58
commit
060ce58f09
1 changed files with 10 additions and 10 deletions
|
@ -544,17 +544,17 @@ QString KStandardDirs::findResourceDir( const char *type,
|
|||
|
||||
bool KStandardDirs::exists(const QString &fullPath)
|
||||
{
|
||||
KDE_struct_stat buff;
|
||||
QByteArray cFullPath = QFile::encodeName(fullPath);
|
||||
if (access(cFullPath, R_OK) == 0 && KDE_stat( cFullPath, &buff ) == 0) {
|
||||
if (!fullPath.endsWith(QLatin1Char('/'))) {
|
||||
if (S_ISREG( buff.st_mode ))
|
||||
return true;
|
||||
} else
|
||||
if (S_ISDIR( buff.st_mode ))
|
||||
return true;
|
||||
#ifndef NDEBUG
|
||||
kDebug(180) << "exists check on" << fullPath;
|
||||
#endif
|
||||
QFileInfo finfo(fullPath);
|
||||
if (!finfo.isReadable()) {
|
||||
return false;
|
||||
} else if (!fullPath.endsWith(QLatin1Char('/'))) {
|
||||
return !finfo.isDir() && finfo.exists();
|
||||
} else {
|
||||
return finfo.isDir() && finfo.exists();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void lookupDirectory(const QString& path, const QString &relPart,
|
||||
|
|
Loading…
Add table
Reference in a new issue