forked from qt-creator/qt-creator
Replace QFile::exists by QFileInfo::exists
QFile::exists only calls QFileInfo::exists, so this saves one function call per invocation. Change-Id: I41cb407345654eeead14455a4955b8b9b015aedc Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -1475,7 +1475,7 @@ public:
|
|||||||
static std::optional<QString> lockedPluginName(PluginManagerPrivate *pm)
|
static std::optional<QString> lockedPluginName(PluginManagerPrivate *pm)
|
||||||
{
|
{
|
||||||
const QString lockFilePath = LockFile::filePath(pm);
|
const QString lockFilePath = LockFile::filePath(pm);
|
||||||
if (QFile::exists(lockFilePath)) {
|
if (QFileInfo::exists(lockFilePath)) {
|
||||||
QFile f(lockFilePath);
|
QFile f(lockFilePath);
|
||||||
if (f.open(QIODevice::ReadOnly)) {
|
if (f.open(QIODevice::ReadOnly)) {
|
||||||
const auto pluginName = QString::fromUtf8(f.readLine()).trimmed();
|
const auto pluginName = QString::fromUtf8(f.readLine()).trimmed();
|
||||||
|
@@ -259,7 +259,7 @@ void ContextPaneWidgetImage::setProperties(QmlJS::PropertyReader *propertyReader
|
|||||||
if (propertyReader->hasProperty(QLatin1String("source"))) {
|
if (propertyReader->hasProperty(QLatin1String("source"))) {
|
||||||
QString source = propertyReader->readProperty(QLatin1String("source")).toString();
|
QString source = propertyReader->readProperty(QLatin1String("source")).toString();
|
||||||
m_fileWidget->setFileName(source);
|
m_fileWidget->setFileName(source);
|
||||||
if (QFile::exists(m_path + QLatin1Char('/') + source))
|
if (QFileInfo::exists(m_path + QLatin1Char('/') + source))
|
||||||
setPixmap(m_path + QLatin1Char('/') + source);
|
setPixmap(m_path + QLatin1Char('/') + source);
|
||||||
else
|
else
|
||||||
setPixmap(source);
|
setPixmap(source);
|
||||||
|
@@ -505,7 +505,7 @@ bool MimeBinaryProvider::loadMimeTypePrivate(MimeTypePrivate &data)
|
|||||||
|
|
||||||
// shared-mime-info since 1.3 lowercases the xml files
|
// shared-mime-info since 1.3 lowercases the xml files
|
||||||
QString mimeFile = m_directory + QLatin1Char('/') + data.name.toLower() + QLatin1String(".xml");
|
QString mimeFile = m_directory + QLatin1Char('/') + data.name.toLower() + QLatin1String(".xml");
|
||||||
if (!QFile::exists(mimeFile))
|
if (!QFileInfo::exists(mimeFile))
|
||||||
mimeFile = m_directory + QLatin1Char('/') + data.name + QLatin1String(".xml"); // pre-1.3
|
mimeFile = m_directory + QLatin1Char('/') + data.name + QLatin1String(".xml"); // pre-1.3
|
||||||
|
|
||||||
QFile qfile(mimeFile);
|
QFile qfile(mimeFile);
|
||||||
|
@@ -111,7 +111,7 @@ bool SaveFile::commit()
|
|||||||
if (!result) {
|
if (!result) {
|
||||||
DWORD replaceErrorCode = GetLastError();
|
DWORD replaceErrorCode = GetLastError();
|
||||||
QString errorStr;
|
QString errorStr;
|
||||||
if (!QFile::exists(finalFileName)) {
|
if (!QFileInfo::exists(finalFileName)) {
|
||||||
// Replace failed because finalFileName does not exist, try rename.
|
// Replace failed because finalFileName does not exist, try rename.
|
||||||
if (!(result = rename(finalFileName)))
|
if (!(result = rename(finalFileName)))
|
||||||
errorStr = errorString();
|
errorStr = errorString();
|
||||||
@@ -148,7 +148,7 @@ bool SaveFile::commit()
|
|||||||
|
|
||||||
// Back up current file.
|
// Back up current file.
|
||||||
// If it's opened by another application, the lock follows the move.
|
// If it's opened by another application, the lock follows the move.
|
||||||
if (QFile::exists(finalFileName)) {
|
if (QFileInfo::exists(finalFileName)) {
|
||||||
// Kill old backup. Might be useful if creator crashed before removing backup.
|
// Kill old backup. Might be useful if creator crashed before removing backup.
|
||||||
QFile::remove(backupName);
|
QFile::remove(backupName);
|
||||||
QFile finalFile(finalFileName);
|
QFile finalFile(finalFileName);
|
||||||
|
@@ -847,7 +847,7 @@ QString StyleHelper::dpiSpecificImageFile(const QString &fileName)
|
|||||||
if (qApp->devicePixelRatio() > 1.0) {
|
if (qApp->devicePixelRatio() > 1.0) {
|
||||||
const QString atDprfileName =
|
const QString atDprfileName =
|
||||||
imageFileWithResolution(fileName, qRound(qApp->devicePixelRatio()));
|
imageFileWithResolution(fileName, qRound(qApp->devicePixelRatio()));
|
||||||
if (QFile::exists(atDprfileName))
|
if (QFileInfo::exists(atDprfileName))
|
||||||
return atDprfileName;
|
return atDprfileName;
|
||||||
}
|
}
|
||||||
return fileName;
|
return fileName;
|
||||||
@@ -867,7 +867,7 @@ QList<int> StyleHelper::availableImageResolutions(const QString &fileName)
|
|||||||
QList<int> result;
|
QList<int> result;
|
||||||
const int maxResolutions = qApp->devicePixelRatio();
|
const int maxResolutions = qApp->devicePixelRatio();
|
||||||
for (int i = 1; i <= maxResolutions; ++i)
|
for (int i = 1; i <= maxResolutions; ++i)
|
||||||
if (QFile::exists(imageFileWithResolution(fileName, i)))
|
if (QFileInfo::exists(imageFileWithResolution(fileName, i)))
|
||||||
result.append(i);
|
result.append(i);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -48,10 +48,10 @@ static FilePath sdkFromUrl(const QUrl &url)
|
|||||||
if (basename.isEmpty())
|
if (basename.isEmpty())
|
||||||
basename = "sdk-tools.zip";
|
basename = "sdk-tools.zip";
|
||||||
|
|
||||||
if (QFile::exists(basename)) {
|
if (QFileInfo::exists(basename)) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
basename += '.';
|
basename += '.';
|
||||||
while (QFile::exists(basename + QString::number(i)))
|
while (QFileInfo::exists(basename + QString::number(i)))
|
||||||
++i;
|
++i;
|
||||||
basename += QString::number(i);
|
basename += QString::number(i);
|
||||||
}
|
}
|
||||||
|
@@ -828,7 +828,7 @@ QStringList ClearCasePluginPrivate::ccGetActiveVobs() const
|
|||||||
// Snapshot views does not necessarily have all active VOBs loaded, so we'll have to
|
// Snapshot views does not necessarily have all active VOBs loaded, so we'll have to
|
||||||
// check if the dirs exists as well. Else the command will work, but the output will
|
// check if the dirs exists as well. Else the command will work, but the output will
|
||||||
// complain about the element not being loaded.
|
// complain about the element not being loaded.
|
||||||
if (QFile::exists(prefix + relativeDir))
|
if (QFileInfo::exists(prefix + relativeDir))
|
||||||
res.append(relativeDir);
|
res.append(relativeDir);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
@@ -391,7 +391,7 @@ void CompilationDatabaseBuildSystem::buildTreeAndProjectParts()
|
|||||||
|
|
||||||
root->addNode(std::make_unique<FileNode>(projectFilePath(), FileType::Project));
|
root->addNode(std::make_unique<FileNode>(projectFilePath(), FileType::Project));
|
||||||
|
|
||||||
if (QFile::exists(dbContents.extraFileName))
|
if (QFileInfo::exists(dbContents.extraFileName))
|
||||||
root->addNode(std::make_unique<FileNode>(Utils::FilePath::fromString(dbContents.extraFileName),
|
root->addNode(std::make_unique<FileNode>(Utils::FilePath::fromString(dbContents.extraFileName),
|
||||||
FileType::Project));
|
FileType::Project));
|
||||||
|
|
||||||
|
@@ -228,7 +228,7 @@ void SourceSettings::fillLanguageIdModel(StringSelectionAspect::ResultCallback c
|
|||||||
auto *newItem = new QStandardItem(language.name);
|
auto *newItem = new QStandardItem(language.name);
|
||||||
newItem->setData(language.id);
|
newItem->setData(language.id);
|
||||||
|
|
||||||
if (QFile::exists(":/compilerexplorer/logos/" + language.logoUrl)) {
|
if (QFileInfo::exists(":/compilerexplorer/logos/" + language.logoUrl)) {
|
||||||
QIcon icon(":/compilerexplorer/logos/" + language.logoUrl);
|
QIcon icon(":/compilerexplorer/logos/" + language.logoUrl);
|
||||||
newItem->setIcon(icon);
|
newItem->setIcon(icon);
|
||||||
}
|
}
|
||||||
|
@@ -957,7 +957,7 @@ void SplitterOrView::restoreState(const QByteArray &state)
|
|||||||
stream >> historyData;
|
stream >> historyData;
|
||||||
view()->m_editorHistory = loadHistory(historyData);
|
view()->m_editorHistory = loadHistory(historyData);
|
||||||
|
|
||||||
if (!QFile::exists(fileName))
|
if (!QFileInfo::exists(fileName))
|
||||||
return;
|
return;
|
||||||
IEditor *e = EditorManagerPrivate::openEditor(view(), FilePath::fromString(fileName), Id::fromString(id),
|
IEditor *e = EditorManagerPrivate::openEditor(view(), FilePath::fromString(fileName), Id::fromString(id),
|
||||||
EditorManager::IgnoreNavigationHistory
|
EditorManager::IgnoreNavigationHistory
|
||||||
|
@@ -174,7 +174,7 @@ static bool hasQmFilesForLocale(const QString &locale, const QString &creatorTrP
|
|||||||
static const QString qtTrPath = QLibraryInfo::path(QLibraryInfo::TranslationsPath);
|
static const QString qtTrPath = QLibraryInfo::path(QLibraryInfo::TranslationsPath);
|
||||||
|
|
||||||
const QString trFile = QLatin1String("/qt_") + locale + QLatin1String(".qm");
|
const QString trFile = QLatin1String("/qt_") + locale + QLatin1String(".qm");
|
||||||
return QFile::exists(qtTrPath + trFile) || QFile::exists(creatorTrPath + trFile);
|
return QFileInfo::exists(qtTrPath + trFile) || QFileInfo::exists(creatorTrPath + trFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralSettingsWidget::fillLanguageBox() const
|
void GeneralSettingsWidget::fillLanguageBox() const
|
||||||
|
@@ -633,7 +633,7 @@ void MimeTypeSettingsPrivate::writeUserModifiedMimeTypes()
|
|||||||
{
|
{
|
||||||
static Utils::FilePath modifiedMimeTypesFile = ICore::userResourcePath(kModifiedMimeTypesFile);
|
static Utils::FilePath modifiedMimeTypesFile = ICore::userResourcePath(kModifiedMimeTypesFile);
|
||||||
|
|
||||||
if (QFile::exists(modifiedMimeTypesFile.toString())
|
if (QFileInfo::exists(modifiedMimeTypesFile.toString())
|
||||||
|| QDir().mkpath(modifiedMimeTypesFile.parentDir().toString())) {
|
|| QDir().mkpath(modifiedMimeTypesFile.parentDir().toString())) {
|
||||||
QFile file(modifiedMimeTypesFile.toString());
|
QFile file(modifiedMimeTypesFile.toString());
|
||||||
if (file.open(QFile::WriteOnly | QFile::Truncate)) {
|
if (file.open(QFile::WriteOnly | QFile::Truncate)) {
|
||||||
|
@@ -109,7 +109,7 @@ public:
|
|||||||
bool isComplete() const final
|
bool isComplete() const final
|
||||||
{
|
{
|
||||||
const FilePath path = m_data->sourcePath;
|
const FilePath path = m_data->sourcePath;
|
||||||
if (!QFile::exists(path.toString())) {
|
if (!QFileInfo::exists(path.toString())) {
|
||||||
m_info->setText(Tr::tr("File does not exist."));
|
m_info->setText(Tr::tr("File does not exist."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -376,7 +376,7 @@ void CompilerOptionsBuilder::addHeaderPathOptions()
|
|||||||
|
|
||||||
void CompilerOptionsBuilder::addIncludeFile(const QString &file)
|
void CompilerOptionsBuilder::addIncludeFile(const QString &file)
|
||||||
{
|
{
|
||||||
if (QFile::exists(file)) {
|
if (QFileInfo::exists(file)) {
|
||||||
add({isClStyle() ? QLatin1String(includeFileOptionCl)
|
add({isClStyle() ? QLatin1String(includeFileOptionCl)
|
||||||
: QLatin1String(includeFileOptionGcc),
|
: QLatin1String(includeFileOptionGcc),
|
||||||
QDir::toNativeSeparators(file)});
|
QDir::toNativeSeparators(file)});
|
||||||
|
@@ -120,7 +120,7 @@ GDB 32bit | Api | Api | NA | Win32
|
|||||||
const QString executable = breakApi == UseWin32Interrupt
|
const QString executable = breakApi == UseWin32Interrupt
|
||||||
? QCoreApplication::applicationDirPath() + "/win32interrupt.exe"
|
? QCoreApplication::applicationDirPath() + "/win32interrupt.exe"
|
||||||
: QCoreApplication::applicationDirPath() + "/win64interrupt.exe";
|
: QCoreApplication::applicationDirPath() + "/win64interrupt.exe";
|
||||||
if (!QFile::exists(executable)) {
|
if (!QFileInfo::exists(executable)) {
|
||||||
*errorMessage = QString::fromLatin1(
|
*errorMessage = QString::fromLatin1(
|
||||||
"%1 does not exist. If you have built %2 "
|
"%1 does not exist. If you have built %2 "
|
||||||
"on your own, checkout "
|
"on your own, checkout "
|
||||||
|
@@ -916,7 +916,7 @@ void setQtPluginPath(const QString &qtPluginPath)
|
|||||||
*sQtPluginPath = Utils::trimBack(*sQtPluginPath, '/');
|
*sQtPluginPath = Utils::trimBack(*sQtPluginPath, '/');
|
||||||
if (sQtPluginPath->endsWith(postfix))
|
if (sQtPluginPath->endsWith(postfix))
|
||||||
sQtPluginPath->chop(postfix.size());
|
sQtPluginPath->chop(postfix.size());
|
||||||
if (!QFile::exists(*sQtPluginPath + postfix)) {
|
if (!QFileInfo::exists(*sQtPluginPath + postfix)) {
|
||||||
qWarning() << qPrintable(
|
qWarning() << qPrintable(
|
||||||
QLatin1String(
|
QLatin1String(
|
||||||
"Warning: The path \"%1\" passed to -designer-qt-pluginpath does not exist. "
|
"Warning: The path \"%1\" passed to -designer-qt-pluginpath does not exist. "
|
||||||
|
@@ -2529,7 +2529,7 @@ FilePath GitClient::gitBinDirectory() const
|
|||||||
// Git for Windows uses Git/usr/bin. Prefer that if it exists.
|
// Git for Windows uses Git/usr/bin. Prefer that if it exists.
|
||||||
QString usrBinPath = path;
|
QString usrBinPath = path;
|
||||||
usrBinPath.replace(usrBinPath.size() - 3, 3, "usr/bin");
|
usrBinPath.replace(usrBinPath.size() - 3, 3, "usr/bin");
|
||||||
if (QFile::exists(usrBinPath))
|
if (QFileInfo::exists(usrBinPath))
|
||||||
path = usrBinPath;
|
path = usrBinPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -372,7 +372,7 @@ void MacroManager::saveLastMacro()
|
|||||||
QString MacroManager::macrosDirectory()
|
QString MacroManager::macrosDirectory()
|
||||||
{
|
{
|
||||||
const QString path = Core::ICore::userResourcePath("macros").toString();
|
const QString path = Core::ICore::userResourcePath("macros").toString();
|
||||||
if (QFile::exists(path) || QDir().mkpath(path))
|
if (QFileInfo::exists(path) || QDir().mkpath(path))
|
||||||
return path;
|
return path;
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ namespace Internal {
|
|||||||
template<typename File_t>
|
template<typename File_t>
|
||||||
bool containsFiles(const QString &path, const File_t &file)
|
bool containsFiles(const QString &path, const File_t &file)
|
||||||
{
|
{
|
||||||
return QFile::exists(QString("%1/%2").arg(path).arg(file));
|
return QFileInfo::exists(QString("%1/%2").arg(path).arg(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename File_t, typename... T>
|
template<typename File_t, typename... T>
|
||||||
|
@@ -163,7 +163,7 @@ GDB 32bit | Api | Api | N/A | Win32
|
|||||||
executable += si == Win32Interrupt
|
executable += si == Win32Interrupt
|
||||||
? QLatin1String("/win32interrupt.exe")
|
? QLatin1String("/win32interrupt.exe")
|
||||||
: QLatin1String("/win64interrupt.exe");
|
: QLatin1String("/win64interrupt.exe");
|
||||||
if (!QFile::exists(executable)) {
|
if (!QFileInfo::exists(executable)) {
|
||||||
appendMsgCannotInterrupt(pid,
|
appendMsgCannotInterrupt(pid,
|
||||||
Tr::tr("%1 does not exist. If you built %2 "
|
Tr::tr("%1 does not exist. If you built %2 "
|
||||||
"yourself, check out https://code.qt.io/cgit/"
|
"yourself, check out https://code.qt.io/cgit/"
|
||||||
|
@@ -1210,8 +1210,8 @@ void MsvcToolChain::rescanForCompiler()
|
|||||||
env.searchInPath(QLatin1String("cl.exe"), {}, [](const Utils::FilePath &name) {
|
env.searchInPath(QLatin1String("cl.exe"), {}, [](const Utils::FilePath &name) {
|
||||||
QDir dir(QDir::cleanPath(name.toFileInfo().absolutePath() + QStringLiteral("/..")));
|
QDir dir(QDir::cleanPath(name.toFileInfo().absolutePath() + QStringLiteral("/..")));
|
||||||
do {
|
do {
|
||||||
if (QFile::exists(dir.absoluteFilePath(QStringLiteral("vcvarsall.bat")))
|
if (QFileInfo::exists(dir.absoluteFilePath(QStringLiteral("vcvarsall.bat")))
|
||||||
|| QFile::exists(dir.absolutePath() + "/Auxiliary/Build/vcvarsall.bat"))
|
|| QFileInfo::exists(dir.absolutePath() + "/Auxiliary/Build/vcvarsall.bat"))
|
||||||
return true;
|
return true;
|
||||||
} while (dir.cdUp() && !dir.isRoot());
|
} while (dir.cdUp() && !dir.isRoot());
|
||||||
return false;
|
return false;
|
||||||
|
@@ -1917,7 +1917,7 @@ FilePaths QmakeProFile::subDirsPaths(QtSupport::ProFileReader *reader,
|
|||||||
else
|
else
|
||||||
realFile = realDir;
|
realFile = realDir;
|
||||||
|
|
||||||
if (QFile::exists(realFile)) {
|
if (QFileInfo::exists(realFile)) {
|
||||||
realFile = QDir::cleanPath(realFile);
|
realFile = QDir::cleanPath(realFile);
|
||||||
subProjectPaths << FilePath::fromString(realFile);
|
subProjectPaths << FilePath::fromString(realFile);
|
||||||
if (subProjectsNotToDeploy && !subProjectsNotToDeploy->contains(realFile)
|
if (subProjectsNotToDeploy && !subProjectsNotToDeploy->contains(realFile)
|
||||||
|
@@ -115,7 +115,7 @@ void AssetsLibraryModel::deleteFiles(const QStringList &filePaths, bool dontAskA
|
|||||||
QmlDesignerPlugin::settings().insert(DesignerSettingsKey::ASK_BEFORE_DELETING_ASSET, false);
|
QmlDesignerPlugin::settings().insert(DesignerSettingsKey::ASK_BEFORE_DELETING_ASSET, false);
|
||||||
|
|
||||||
for (const QString &filePath : filePaths) {
|
for (const QString &filePath : filePaths) {
|
||||||
if (QFile::exists(filePath) && !QFile::remove(filePath)) {
|
if (QFileInfo::exists(filePath) && !QFile::remove(filePath)) {
|
||||||
QMessageBox::warning(Core::ICore::dialogParent(),
|
QMessageBox::warning(Core::ICore::dialogParent(),
|
||||||
tr("Failed to Delete File"),
|
tr("Failed to Delete File"),
|
||||||
tr("Could not delete \"%1\".").arg(filePath));
|
tr("Could not delete \"%1\".").arg(filePath));
|
||||||
|
@@ -86,7 +86,7 @@ bool fileComponentExists(const ModelNode &modelNode)
|
|||||||
if (fileName.contains("qml/QtQuick"))
|
if (fileName.contains("qml/QtQuick"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return QFile::exists(fileName);
|
return QFileInfo::exists(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool selectionIsComponent(const SelectionContext &selectionState)
|
bool selectionIsComponent(const SelectionContext &selectionState)
|
||||||
|
@@ -291,7 +291,7 @@ void ContentLibraryMaterialsModel::loadMaterialBundle(const QDir &matBundleDir)
|
|||||||
for (const QString &s : std::as_const(sharedFiles)) {
|
for (const QString &s : std::as_const(sharedFiles)) {
|
||||||
const QString fullSharedFilePath = matBundleDir.filePath(s);
|
const QString fullSharedFilePath = matBundleDir.filePath(s);
|
||||||
|
|
||||||
if (!QFile::exists(fullSharedFilePath))
|
if (!QFileInfo::exists(fullSharedFilePath))
|
||||||
missingSharedFiles.push_back(s);
|
missingSharedFiles.push_back(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -165,7 +165,7 @@ void LocalQmlProfilerRunnerTest::testFindFreeSocket()
|
|||||||
QUrl serverUrl = Utils::urlFromLocalSocket();
|
QUrl serverUrl = Utils::urlFromLocalSocket();
|
||||||
QString socket = serverUrl.path();
|
QString socket = serverUrl.path();
|
||||||
QVERIFY(!socket.isEmpty());
|
QVERIFY(!socket.isEmpty());
|
||||||
QVERIFY(!QFile::exists(socket));
|
QVERIFY(!QFileInfo::exists(socket));
|
||||||
QFile file(socket);
|
QFile file(socket);
|
||||||
QVERIFY(file.open(QIODevice::WriteOnly));
|
QVERIFY(file.open(QIODevice::WriteOnly));
|
||||||
file.close();
|
file.close();
|
||||||
|
@@ -822,7 +822,7 @@ static QString qtVersionsFile(const QString &baseDir)
|
|||||||
static std::optional<FilePath> currentlyLinkedQtDir(bool *hasInstallSettings)
|
static std::optional<FilePath> currentlyLinkedQtDir(bool *hasInstallSettings)
|
||||||
{
|
{
|
||||||
const QString installSettingsFilePath = settingsFile(Core::ICore::resourcePath().toString());
|
const QString installSettingsFilePath = settingsFile(Core::ICore::resourcePath().toString());
|
||||||
const bool installSettingsExist = QFile::exists(installSettingsFilePath);
|
const bool installSettingsExist = QFileInfo::exists(installSettingsFilePath);
|
||||||
if (hasInstallSettings)
|
if (hasInstallSettings)
|
||||||
*hasInstallSettings = installSettingsExist;
|
*hasInstallSettings = installSettingsExist;
|
||||||
if (installSettingsExist) {
|
if (installSettingsExist) {
|
||||||
@@ -934,8 +934,8 @@ static std::optional<FilePath> settingsDirForQtDir(const FilePath &baseDirectory
|
|||||||
return qtDir / dir;
|
return qtDir / dir;
|
||||||
});
|
});
|
||||||
const FilePath validDir = Utils::findOrDefault(dirsToCheck, [baseDirectory](const FilePath &dir) {
|
const FilePath validDir = Utils::findOrDefault(dirsToCheck, [baseDirectory](const FilePath &dir) {
|
||||||
return QFile::exists(settingsFile(baseDirectory.resolvePath(dir).toString()))
|
return QFileInfo::exists(settingsFile(baseDirectory.resolvePath(dir).toString()))
|
||||||
|| QFile::exists(qtVersionsFile(baseDirectory.resolvePath(dir).toString()));
|
|| QFileInfo::exists(qtVersionsFile(baseDirectory.resolvePath(dir).toString()));
|
||||||
});
|
});
|
||||||
if (!validDir.isEmpty())
|
if (!validDir.isEmpty())
|
||||||
return validDir;
|
return validDir;
|
||||||
|
@@ -229,7 +229,7 @@ QString ResolveLocationContext::execCopyFileDialog(QWidget *parent, const QDir &
|
|||||||
// Helper to copy a file with message boxes
|
// Helper to copy a file with message boxes
|
||||||
static inline bool copyFile(const QString &file, const QString ©Name, QWidget *parent)
|
static inline bool copyFile(const QString &file, const QString ©Name, QWidget *parent)
|
||||||
{
|
{
|
||||||
if (QFile::exists(copyName)) {
|
if (QFileInfo::exists(copyName)) {
|
||||||
if (!QFile::remove(copyName)) {
|
if (!QFile::remove(copyName)) {
|
||||||
QMessageBox::critical(parent, Tr::tr("Overwriting Failed"),
|
QMessageBox::critical(parent, Tr::tr("Overwriting Failed"),
|
||||||
Tr::tr("Could not overwrite file %1.")
|
Tr::tr("Could not overwrite file %1.")
|
||||||
|
@@ -50,7 +50,7 @@ void File::checkExistence()
|
|||||||
bool File::exists()
|
bool File::exists()
|
||||||
{
|
{
|
||||||
if (!m_checked) {
|
if (!m_checked) {
|
||||||
m_exists = QFile::exists(name);
|
m_exists = QFileInfo::exists(name);
|
||||||
m_checked = true;
|
m_checked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,7 +363,7 @@ bool ResourceFile::renameFile(const QString &fileName, const QString &newFileNam
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
const bool exists = QFile::exists(newFileName);
|
const bool exists = QFileInfo::exists(newFileName);
|
||||||
for (File *file : std::as_const(entries)) {
|
for (File *file : std::as_const(entries)) {
|
||||||
file->name = newFileName;
|
file->name = newFileName;
|
||||||
file->setExists(exists);
|
file->setExists(exists);
|
||||||
@@ -1230,7 +1230,7 @@ EntryBackup * RelativeResourceModel::removeEntry(const QModelIndex &index)
|
|||||||
} else {
|
} else {
|
||||||
const QString fileNameBackup = file(index);
|
const QString fileNameBackup = file(index);
|
||||||
const QString aliasBackup = alias(index);
|
const QString aliasBackup = alias(index);
|
||||||
if (!QFile::exists(fileNameBackup)) {
|
if (!QFileInfo::exists(fileNameBackup)) {
|
||||||
deleteItem(index);
|
deleteItem(index);
|
||||||
return new FileEntryBackup(*this, prefixIndex.row(), index.row(), fileNameBackup, aliasBackup);
|
return new FileEntryBackup(*this, prefixIndex.row(), index.row(), fileNameBackup, aliasBackup);
|
||||||
}
|
}
|
||||||
|
@@ -349,7 +349,7 @@ bool ScxmlDocument::pasteData(const QByteArray &data, const QPointF &minPos, con
|
|||||||
|
|
||||||
void ScxmlDocument::load(const QString &fileName)
|
void ScxmlDocument::load(const QString &fileName)
|
||||||
{
|
{
|
||||||
if (QFile::exists(fileName)) {
|
if (QFileInfo::exists(fileName)) {
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
if (load(&file)) {
|
if (load(&file)) {
|
||||||
|
@@ -778,7 +778,7 @@ void MemcheckToolPrivate::heobAction()
|
|||||||
// heob executable
|
// heob executable
|
||||||
const QString heob = QString("heob%1.exe").arg(abi.wordWidth());
|
const QString heob = QString("heob%1.exe").arg(abi.wordWidth());
|
||||||
const QString heobPath = dialog.path() + '/' + heob;
|
const QString heobPath = dialog.path() + '/' + heob;
|
||||||
if (!QFile::exists(heobPath)) {
|
if (!QFileInfo::exists(heobPath)) {
|
||||||
QMessageBox::critical(
|
QMessageBox::critical(
|
||||||
Core::ICore::dialogParent(),
|
Core::ICore::dialogParent(),
|
||||||
Tr::tr("Heob"),
|
Tr::tr("Heob"),
|
||||||
@@ -791,7 +791,7 @@ void MemcheckToolPrivate::heobAction()
|
|||||||
if (abi.osFlavor() == Abi::WindowsMSysFlavor) {
|
if (abi.osFlavor() == Abi::WindowsMSysFlavor) {
|
||||||
const QString dwarfstack = QString("dwarfstack%1.dll").arg(abi.wordWidth());
|
const QString dwarfstack = QString("dwarfstack%1.dll").arg(abi.wordWidth());
|
||||||
const QString dwarfstackPath = dialog.path() + '/' + dwarfstack;
|
const QString dwarfstackPath = dialog.path() + '/' + dwarfstack;
|
||||||
if (!QFile::exists(dwarfstackPath)
|
if (!QFileInfo::exists(dwarfstackPath)
|
||||||
&& CheckableMessageBox::information(
|
&& CheckableMessageBox::information(
|
||||||
Core::ICore::dialogParent(),
|
Core::ICore::dialogParent(),
|
||||||
Tr::tr("Heob"),
|
Tr::tr("Heob"),
|
||||||
|
@@ -91,7 +91,7 @@ static QString makeFrameName(const Frame &frame, bool withLocation)
|
|||||||
else
|
else
|
||||||
path = frame.object();
|
path = frame.object();
|
||||||
|
|
||||||
if (QFile::exists(path))
|
if (QFileInfo::exists(path))
|
||||||
path = QFileInfo(path).canonicalFilePath();
|
path = QFileInfo(path).canonicalFilePath();
|
||||||
|
|
||||||
if (frame.line() != -1)
|
if (frame.line() != -1)
|
||||||
|
@@ -1156,7 +1156,7 @@ void VcsBaseEditorWidget::jumpToChangeFromDiff(QTextCursor cursor)
|
|||||||
return;
|
return;
|
||||||
const QString fileName = findDiffFile(fileNameFromDiffSpecification(block));
|
const QString fileName = findDiffFile(fileNameFromDiffSpecification(block));
|
||||||
|
|
||||||
const bool exists = fileName.isEmpty() ? false : QFile::exists(fileName);
|
const bool exists = fileName.isEmpty() ? false : QFileInfo::exists(fileName);
|
||||||
|
|
||||||
if (!exists)
|
if (!exists)
|
||||||
return;
|
return;
|
||||||
|
@@ -79,7 +79,7 @@ QString QMakeGlobals::cleanSpec(QMakeCmdLineParserState &state, const QString &s
|
|||||||
QString ret = QDir::cleanPath(spec);
|
QString ret = QDir::cleanPath(spec);
|
||||||
if (ret.contains(QLatin1Char('/'))) {
|
if (ret.contains(QLatin1Char('/'))) {
|
||||||
QString absRet = IoUtils::resolvePath(device_root, state.pwd, ret);
|
QString absRet = IoUtils::resolvePath(device_root, state.pwd, ret);
|
||||||
if (QFile::exists(absRet))
|
if (QFileInfo::exists(absRet))
|
||||||
ret = absRet;
|
ret = absRet;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -554,7 +554,7 @@ int main(int argc, char *argv[])
|
|||||||
// Process files
|
// Process files
|
||||||
const QStringList files = args;
|
const QStringList files = args;
|
||||||
for (const QString &fileName : files) {
|
for (const QString &fileName : files) {
|
||||||
if (! QFile::exists(fileName)) {
|
if (! QFileInfo::exists(fileName)) {
|
||||||
std::cerr << "Error: File \"" << qPrintable(fileName) << "\" does not exist."
|
std::cerr << "Error: File \"" << qPrintable(fileName) << "\" does not exist."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@@ -76,7 +76,7 @@ SystemPreprocessor::SystemPreprocessor(bool verbose)
|
|||||||
void SystemPreprocessor::check() const
|
void SystemPreprocessor::check() const
|
||||||
{
|
{
|
||||||
QTextStream out(stderr);
|
QTextStream out(stderr);
|
||||||
if (!QFile::exists(QLatin1String(PATH_PREPROCESSOR_CONFIG))) {
|
if (!QFileInfo::exists(QLatin1String(PATH_PREPROCESSOR_CONFIG))) {
|
||||||
out << QString::fromLatin1("Error: File \"%1\" does not exist.")
|
out << QString::fromLatin1("Error: File \"%1\" does not exist.")
|
||||||
.arg(QLatin1String(PATH_PREPROCESSOR_CONFIG))
|
.arg(QLatin1String(PATH_PREPROCESSOR_CONFIG))
|
||||||
<< Qt::endl;
|
<< Qt::endl;
|
||||||
@@ -94,7 +94,7 @@ void SystemPreprocessor::check() const
|
|||||||
void SystemPreprocessor::preprocessFile(const QString &inputFile, const QString &outputFile) const
|
void SystemPreprocessor::preprocessFile(const QString &inputFile, const QString &outputFile) const
|
||||||
{
|
{
|
||||||
check();
|
check();
|
||||||
if (!QFile::exists(inputFile)) {
|
if (!QFileInfo::exists(inputFile)) {
|
||||||
QTextStream out(stderr);
|
QTextStream out(stderr);
|
||||||
out << QString::fromLatin1("Error: File \"%1\" does not exist.").arg(inputFile) << Qt::endl;
|
out << QString::fromLatin1("Error: File \"%1\" does not exist.").arg(inputFile) << Qt::endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@@ -1606,7 +1606,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
QDir cplusplusDir(pathCppFrontend);
|
QDir cplusplusDir(pathCppFrontend);
|
||||||
if (!QFile::exists(pathCppFrontend)) {
|
if (!QFileInfo::exists(pathCppFrontend)) {
|
||||||
std::cerr << "Error: Directory \"" << qPrintable(cplusplusDir.absolutePath())
|
std::cerr << "Error: Directory \"" << qPrintable(cplusplusDir.absolutePath())
|
||||||
<< "\" does not exist." << std::endl;
|
<< "\" does not exist." << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
@@ -1616,7 +1616,7 @@ int main(int argc, char *argv[])
|
|||||||
<< "\"." << std::endl;
|
<< "\"." << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if (!QFile::exists(pathDumpersFile)) {
|
if (!QFileInfo::exists(pathDumpersFile)) {
|
||||||
std::cerr << "Error: File \"" << qPrintable(pathDumpersFile)
|
std::cerr << "Error: File \"" << qPrintable(pathDumpersFile)
|
||||||
<< "\" does not exist." << std::endl;
|
<< "\" does not exist." << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@@ -108,14 +108,14 @@ void QmlPuppet::initQmlRunner()
|
|||||||
|
|
||||||
if (m_argParser.isSet("readcapturedstream") && m_coreApp->arguments().count() > 2) {
|
if (m_argParser.isSet("readcapturedstream") && m_coreApp->arguments().count() > 2) {
|
||||||
QString fileName = m_argParser.value("readcapturedstream");
|
QString fileName = m_argParser.value("readcapturedstream");
|
||||||
if (!QFile::exists(fileName)) {
|
if (!QFileInfo::exists(fileName)) {
|
||||||
qDebug() << "Input stream does not exist:" << fileName;
|
qDebug() << "Input stream does not exist:" << fileName;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_coreApp->arguments().count() > 3) {
|
if (m_coreApp->arguments().count() > 3) {
|
||||||
fileName = m_coreApp->arguments().at(3);
|
fileName = m_coreApp->arguments().at(3);
|
||||||
if (!QFile::exists(fileName)) {
|
if (!QFileInfo::exists(fileName)) {
|
||||||
qDebug() << "Output stream does not exist:" << fileName;
|
qDebug() << "Output stream does not exist:" << fileName;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
@@ -173,7 +173,7 @@ bool SdkSaveFile::commit()
|
|||||||
if (!result) {
|
if (!result) {
|
||||||
DWORD replaceErrorCode = GetLastError();
|
DWORD replaceErrorCode = GetLastError();
|
||||||
QString errorStr;
|
QString errorStr;
|
||||||
if (!QFile::exists(finalFileName)) {
|
if (!QFileInfo::exists(finalFileName)) {
|
||||||
// Replace failed because finalFileName does not exist, try rename.
|
// Replace failed because finalFileName does not exist, try rename.
|
||||||
if (!(result = rename(finalFileName)))
|
if (!(result = rename(finalFileName)))
|
||||||
errorStr = errorString();
|
errorStr = errorString();
|
||||||
@@ -210,7 +210,7 @@ bool SdkSaveFile::commit()
|
|||||||
|
|
||||||
// Back up current file.
|
// Back up current file.
|
||||||
// If it's opened by another application, the lock follows the move.
|
// If it's opened by another application, the lock follows the move.
|
||||||
if (QFile::exists(finalFileName)) {
|
if (QFileInfo::exists(finalFileName)) {
|
||||||
// Kill old backup. Might be useful if creator crashed before removing backup.
|
// Kill old backup. Might be useful if creator crashed before removing backup.
|
||||||
QFile::remove(backupName);
|
QFile::remove(backupName);
|
||||||
QFile finalFile(finalFileName);
|
QFile finalFile(finalFileName);
|
||||||
|
@@ -1252,7 +1252,7 @@ void tst_Dumpers::initTestCase()
|
|||||||
QString cdbextPath = qEnvironmentVariable("QTC_CDBEXT_PATH");
|
QString cdbextPath = qEnvironmentVariable("QTC_CDBEXT_PATH");
|
||||||
if (cdbextPath.isEmpty())
|
if (cdbextPath.isEmpty())
|
||||||
cdbextPath = QString(CDBEXT_PATH "\\qtcreatorcdbext64");
|
cdbextPath = QString(CDBEXT_PATH "\\qtcreatorcdbext64");
|
||||||
QVERIFY(QFile::exists(cdbextPath + "\\qtcreatorcdbext.dll"));
|
QVERIFY(QFileInfo::exists(cdbextPath + "\\qtcreatorcdbext.dll"));
|
||||||
env.set("_NT_DEBUGGER_EXTENSION_PATH", cdbextPath);
|
env.set("_NT_DEBUGGER_EXTENSION_PATH", cdbextPath);
|
||||||
env.prependOrSetPath(Utils::FilePath::fromString(m_qmakeBinary).parentDir());
|
env.prependOrSetPath(Utils::FilePath::fromString(m_qmakeBinary).parentDir());
|
||||||
m_makeBinary = env.searchInPath("nmake.exe").toString();
|
m_makeBinary = env.searchInPath("nmake.exe").toString();
|
||||||
|
Reference in New Issue
Block a user