Commit a439483d authored by hjk's avatar hjk
Browse files

Use QFileInfo::exist(f) instead of QFileInfo(f).exists() if possible



Faster.

Change-Id: I91aa67462e11ff3258600d7f158de79942d0dc81
Reviewed-by: default avatarMarc Reilly <marc.reilly@gmail.com>
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent 1e9b561c
......@@ -142,7 +142,7 @@ void SshKeyCreationDialog::saveKeys()
bool SshKeyCreationDialog::userForbidsOverwriting()
{
if (!QFileInfo(privateKeyFilePath()).exists() && !QFileInfo(publicKeyFilePath()).exists())
if (!QFileInfo::exists(privateKeyFilePath()) && !QFileInfo::exists(publicKeyFilePath()))
return false;
const QMessageBox::StandardButton reply = QMessageBox::question(this, tr("File Exists"),
tr("There already is a file of that name. Do you want to overwrite it?"),
......
......@@ -269,7 +269,7 @@ bool BuildableHelperLibrary::buildHelper(const BuildHelperArguments &arguments,
log->append(newline);
const FileName makeFullPath = arguments.environment.searchInPath(arguments.makeCommand);
if (QFileInfo(arguments.directory + QLatin1String("/Makefile")).exists()) {
if (QFileInfo::exists(arguments.directory + QLatin1String("/Makefile"))) {
if (makeFullPath.isEmpty()) {
*errorMessage = QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary",
"%1 not found in PATH\n").arg(arguments.makeCommand);
......
......@@ -1213,7 +1213,7 @@ static FileName javaHomeForJavac(const FileName &location)
while (tries > 0) {
QDir dir = fileInfo.dir();
dir.cdUp();
if (QFileInfo(dir.filePath(QLatin1String("lib/tools.jar"))).exists())
if (QFileInfo::exists(dir.filePath(QLatin1String("lib/tools.jar"))))
return FileName::fromString(dir.path());
if (fileInfo.isSymLink())
fileInfo.setFile(fileInfo.symLinkTarget());
......@@ -1252,7 +1252,7 @@ void AndroidConfigurations::load()
}
} else if (HostOsInfo::isMacHost()) {
QString javaHome = QLatin1String("/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home");
if (QFileInfo(javaHome).exists())
if (QFileInfo::exists(javaHome))
m_config.setOpenJDKLocation(Utils::FileName::fromString(javaHome));
} else if (HostOsInfo::isWindowsHost()) {
QSettings settings(QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE\\Javasoft\\Java Development Kit"), QSettings::NativeFormat);
......@@ -1275,7 +1275,7 @@ void AndroidConfigurations::load()
settings.beginGroup(version);
QString tmpJavaHome = settings.value(QLatin1String("JavaHome")).toString();
settings.endGroup();
if (!QFileInfo(tmpJavaHome).exists())
if (!QFileInfo::exists(tmpJavaHome))
continue;
major = tmpMajor;
......
......@@ -1259,7 +1259,7 @@ QIcon AndroidManifestEditorWidget::icon(const QString &baseDir, IconDPI dpi)
void AndroidManifestEditorWidget::copyIcon(IconDPI dpi, const QString &baseDir, const QString &filePath)
{
if (!QFileInfo(filePath).exists())
if (!QFileInfo::exists(filePath))
return;
const QString targetPath = iconPath(baseDir, dpi);
......
......@@ -122,7 +122,7 @@ void AndroidToolChain::addToEnvironment(Environment &env) const
env.set(QLatin1String("ANDROID_NDK_TOOLS_PREFIX"), AndroidConfig::toolsPrefix(targetAbi().architecture()));
env.set(QLatin1String("ANDROID_NDK_TOOLCHAIN_VERSION"), m_ndkToolChainVersion);
QString javaHome = AndroidConfigurations::currentConfig().openJDKLocation().toString();
if (!javaHome.isEmpty() && QFileInfo(javaHome).exists())
if (!javaHome.isEmpty() && QFileInfo::exists(javaHome))
env.set(QLatin1String("JAVA_HOME"), javaHome);
env.set(QLatin1String("ANDROID_HOME"), AndroidConfigurations::currentConfig().sdkLocation().toString());
env.set(QLatin1String("ANDROID_SDK_ROOT"), AndroidConfigurations::currentConfig().sdkLocation().toString());
......
......@@ -173,9 +173,8 @@ void AutoreconfStep::run(QFutureInterface<bool> &interface)
// Check whether we need to run autoreconf
const QString projectDir(bc->target()->project()->projectDirectory().toString());
const QFileInfo configureInfo(projectDir + QLatin1String("/configure"));
if (!configureInfo.exists())
if (!QFileInfo::exists(projectDir + QLatin1String("/configure")))
m_runAutoreconf = true;
if (!m_runAutoreconf) {
......
......@@ -219,7 +219,7 @@ CMakeEditorWidget::Link CMakeEditorWidget::findLinkAt(const QTextCursor &cursor,
if (fi.isDir()) {
QDir subDir(fi.absoluteFilePath());
QString subProject = subDir.filePath(QLatin1String("CMakeLists.txt"));
if (QFileInfo(subProject).exists())
if (QFileInfo::exists(subProject))
fileName = subProject;
else
return link;
......
......@@ -147,10 +147,7 @@ CMakeManager *CMakeOpenProjectWizard::cmakeManager() const
bool CMakeOpenProjectWizard::hasInSourceBuild() const
{
QFileInfo fi(m_sourceDirectory + QLatin1String("/CMakeCache.txt"));
if (fi.exists())
return true;
return false;
return QFileInfo::exists(m_sourceDirectory + QLatin1String("/CMakeCache.txt"));
}
bool CMakeOpenProjectWizard::compatibleKitExist() const
......
......@@ -379,9 +379,9 @@ BaseFileWizardFactory::OverwriteResult BaseFileWizardFactory::promptOverwrite(Ge
static const QString symLinkMsg = tr("[symbolic link]");
foreach (const GeneratedFile &file, *files) {
const QFileInfo fi(file.path());
if (fi.exists())
existingFiles.append(file.path());
const QString path = file.path();
if (QFileInfo::exists(path))
existingFiles.append(path);
}
if (existingFiles.isEmpty())
return OverwriteOk;
......
......@@ -441,7 +441,7 @@ void HelpManager::verifyDocumenation()
{
const QStringList &registeredDocs = d->m_helpEngine->registeredDocumentations();
foreach (const QString &nameSpace, registeredDocs) {
if (!QFileInfo(d->m_helpEngine->documentationFileName(nameSpace)).exists())
if (!QFileInfo::exists(d->m_helpEngine->documentationFileName(nameSpace)))
d->m_nameSpacesToUnregister.append(nameSpace);
}
}
......
......@@ -410,8 +410,7 @@ QString ICore::userResourcePath()
const QString configDir = QFileInfo(settings(QSettings::UserScope)->fileName()).path();
const QString urp = configDir + QLatin1String("/qtcreator");
QFileInfo fi(urp + QLatin1Char('/'));
if (!fi.exists()) {
if (!QFileInfo::exists(urp + QLatin1Char('/'))) {
QDir dir;
if (!dir.mkpath(urp))
qWarning() << "could not create" << urp;
......
......@@ -134,7 +134,7 @@ QList<LocatorFilterEntry> FileSystemFilter::matchesFor(QFutureInterface<Core::Lo
// "create and open" functionality
const QString fullFilePath = dirInfo.filePath(name);
if (!QFileInfo(fullFilePath).exists() && dirInfo.exists()) {
if (!QFileInfo::exists(fullFilePath) && dirInfo.exists()) {
LocatorFilterEntry createAndOpen(this, tr("Create and Open \"%1\"").arg(entry), fullFilePath);
createAndOpen.extraInfo = Utils::FileUtils::shortNativePath(
Utils::FileName::fromString(dirInfo.absolutePath()));
......
......@@ -171,8 +171,7 @@ TestActionsTestCase::TestActionsTestCase(const Actions &tokenActions, const Acti
// Process all files from the projects
foreach (const QString filePath, filesToOpen) {
// Skip e.g. "<configuration>"
const QFileInfo fileInfo(filePath);
if (!fileInfo.exists())
if (!QFileInfo::exists(filePath))
continue;
qDebug() << " --" << filePath;
......
......@@ -123,7 +123,7 @@ public:
ExampleProjectConfigurator(const QString &projectFile)
{
const QString projectUserFile = projectFile + _(".user");
QVERIFY(!QFileInfo(projectUserFile).exists());
QVERIFY(!QFileInfo::exists(projectUserFile));
// Open project
QString errorOpeningProject;
......
......@@ -195,7 +195,7 @@ bool TestCase::writeFile(const QString &filePath, const QByteArray &contents)
FileWriterAndRemover::FileWriterAndRemover(const QString &filePath, const QByteArray &contents)
: m_filePath(filePath)
{
if (QFileInfo(filePath).exists()) {
if (QFileInfo::exists(filePath)) {
const QString warning = QString::fromLatin1(
"Will not overwrite existing file: \"%1\"."
" If this file is left over due to a(n) abort/crash, please remove manually.")
......
......@@ -1417,7 +1417,7 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
//qDebug() << "BP " << rid << data.toString();
// Quickly set the location marker.
if (lineNumber && !boolSetting(OperateByInstruction)
&& QFileInfo(fullName).exists()
&& QFileInfo::exists(fullName)
&& !isQmlStepBreakpoint(rid)
&& !isQFatalBreakpoint(rid))
gotoLocation(Location(fullName, lineNumber));
......
......@@ -172,22 +172,22 @@ void GdbServerStarter::attach(int port)
QString binary;
QString localExecutable;
QString candidate = sysroot + d->process.exe;
if (QFileInfo(candidate).exists())
if (QFileInfo::exists(candidate))
localExecutable = candidate;
if (localExecutable.isEmpty()) {
binary = d->process.cmdLine.section(QLatin1Char(' '), 0, 0);
candidate = sysroot + QLatin1Char('/') + binary;
if (QFileInfo(candidate).exists())
if (QFileInfo::exists(candidate))
localExecutable = candidate;
}
if (localExecutable.isEmpty()) {
candidate = sysroot + QLatin1String("/usr/bin/") + binary;
if (QFileInfo(candidate).exists())
if (QFileInfo::exists(candidate))
localExecutable = candidate;
}
if (localExecutable.isEmpty()) {
candidate = sysroot + QLatin1String("/bin/") + binary;
if (QFileInfo(candidate).exists())
if (QFileInfo::exists(candidate))
localExecutable = candidate;
}
if (localExecutable.isEmpty()) {
......
......@@ -768,7 +768,7 @@ void PdbEngine::handleBacktrace(const PdbResponse &response)
frame.line = lineNumber;
frame.function = _(line.mid(pos2 + 1));
frame.usable = QFileInfo(frame.file).isReadable();
if (frame.line > 0 && QFileInfo(frame.file).exists()) {
if (frame.line > 0 && QFileInfo::exists(frame.file)) {
if (line.startsWith("> "))
currentIndex = level;
frame.level = level;
......
......@@ -3225,8 +3225,8 @@ bool GitClient::synchronousMerge(const QString &workingDirectory, const QString
bool GitClient::canRebase(const QString &workingDirectory) const
{
const QString gitDir = findGitDirForRepository(workingDirectory);
if (QFileInfo(gitDir + QLatin1String("/rebase-apply")).exists()
|| QFileInfo(gitDir + QLatin1String("/rebase-merge")).exists()) {
if (QFileInfo::exists(gitDir + QLatin1String("/rebase-apply"))
|| QFileInfo::exists(gitDir + QLatin1String("/rebase-merge"))) {
VcsOutputWindow::appendError(
tr("Rebase, merge or am is in progress. Finish "
"or abort it and then try again."));
......
......@@ -117,7 +117,7 @@ void IosRunner::start()
}
m_cleanExit = false;
m_qmlPort = 0;
if (!QFileInfo(m_bundleDir).exists()) {
if (!QFileInfo::exists(m_bundleDir)) {
TaskHub::addTask(Task::Warning,
tr("Could not find %1.").arg(m_bundleDir),
ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT);
......
Supports Markdown
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