Commit 20fefd0b authored by Alexander Volkov's avatar Alexander Volkov

Use QTemporaryDir::filePath() instead of path concatenation

Summary:
This is the preferred way to get a file path in a temporary
directory. It's easy to forget to append '/' when using
QTemporaryDir::path().

Reviewers: #plasma, hein

Reviewed By: #plasma, hein

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D10038
parent fe9cda3a
......@@ -77,12 +77,12 @@ QSet<QUrl> extract(const QString &fileName, QTemporaryDir **tempDir)
// unhide 1st!
if(Misc::isHidden(name))
{
::rename(QFile::encodeName((*tempDir)->path()+QLatin1Char('/')+name).data(),
QFile::encodeName((*tempDir)->path()+QLatin1Char('/')+name.mid(1)).data());
::rename(QFile::encodeName((*tempDir)->filePath(name)).data(),
QFile::encodeName((*tempDir)->filePath(name.mid(1))).data());
name=name.mid(1);
}
urls.insert(QUrl((*tempDir)->path()+QLatin1Char('/')+name));
urls.insert(QUrl((*tempDir)->filePath(name)));
}
}
}
......
......@@ -713,7 +713,7 @@ QString CJobRunner::fileName(const QUrl &url)
itsTempDir->setAutoRemove(true);
}
QString tempName(itsTempDir->path()+QLatin1Char('/')+Misc::getFile(url.path()));
QString tempName(itsTempDir->filePath(Misc::getFile(url.path())));
auto job = KIO::file_copy(url, QUrl::fromLocalFile(tempName), -1, KIO::Overwrite);
if (job->exec())
return tempName;
......
......@@ -234,7 +234,7 @@ void CKioFonts::put(const QUrl &url, int /*permissions*/, KIO::JobFlags /*flags*
itsTempDir->setAutoRemove(true);
}
QString tempFile(itsTempDir->path()+QLatin1Char('/')+url.fileName());
QString tempFile(itsTempDir->filePath(url.fileName()));
QFile dest(tempFile);
if (dest.open(QIODevice::WriteOnly))
......
......@@ -91,16 +91,16 @@ bool CFontThumbnail::create(const QString &path, int width, int height, QImage &
((KArchiveFile *)entry)->copyTo(tempDir->path());
QString mime(db.mimeTypeForFile(tempDir->path()+QLatin1Char('/')+entry->name()).name());
QString mime(db.mimeTypeForFile(tempDir->filePath(entry->name())).name());
if(mime=="font/ttf" || mime=="font/otf" || mime=="application/x-font-ttf" ||
mime=="application/x-font-otf" || mime=="application/x-font-type1")
{
realPath=tempDir->path()+QLatin1Char('/')+entry->name();
realPath=tempDir->filePath(entry->name());
break;
}
else
::unlink(QFile::encodeName(tempDir->path()+QLatin1Char('/')+entry->name()).data());
::unlink(QFile::encodeName(tempDir->filePath(entry->name())).data());
}
}
}
......
......@@ -317,18 +317,18 @@ void CFontViewPart::timeout()
((KArchiveFile *)entry)->copyTo(itsTempDir->path());
QMimeDatabase db;
QString mime(db.mimeTypeForFile(itsTempDir->path()+QLatin1Char('/')+entry->name()).name());
QString mime(db.mimeTypeForFile(itsTempDir->filePath(entry->name())).name());
if(mime=="font/ttf" || mime=="font/otf" || mime=="application/x-font-ttf" ||
mime=="application/x-font-otf" || mime=="application/x-font-type1")
{
fontFile=itsTempDir->path()+QLatin1Char('/')+entry->name();
fontFile=itsTempDir->filePath(entry->name());
//setLocalFilePath(itsTempDir->path()+QLatin1Char('/')+entry->name());
// itsMetaUrl=QUrl::fromLocalFile(localFilePath());
break;
}
else
::unlink(QFile::encodeName(itsTempDir->path()+QLatin1Char('/')+entry->name()).data());
::unlink(QFile::encodeName(itsTempDir->filePath(entry->name())).data());
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment