forked from qt-creator/qt-creator
Utils: Introduce a TemporaryDirectory and TemporaryFile class
Both wrap the corresponding Qt class, but make sure all temporary files or directories are created inside a "master temporary directory". Change-Id: I55461be507c828c965224c02863ea5ed9bbf9498 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
committed by
Tim Jenssen
parent
e6017c40fc
commit
c6f90e575e
@@ -31,8 +31,10 @@
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <extensionsystem/pluginspec.h>
|
||||
#include <qtsingleapplication.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
@@ -278,6 +280,8 @@ void loadFonts()
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Utils::TemporaryDirectory::setMasterTemporaryDirectory(QDir::tempPath() + "/QtCreator-XXXXXX");
|
||||
|
||||
const char *highDpiEnvironmentVariable = setHighDpiEnvironmentVariable();
|
||||
|
||||
QLoggingCategory::setFilterRules(QLatin1String("qtc.*.debug=false\nqtc.*.info=false"));
|
||||
@@ -345,11 +349,9 @@ int main(int argc, char **argv)
|
||||
testOptionProvided = true;
|
||||
}
|
||||
}
|
||||
QScopedPointer<QTemporaryDir> temporaryCleanSettingsDir;
|
||||
QScopedPointer<Utils::TemporaryDirectory> temporaryCleanSettingsDir;
|
||||
if (settingsPath.isEmpty() && testOptionProvided) {
|
||||
const QString settingsPathTemplate = QDir::cleanPath(QDir::tempPath()
|
||||
+ QString::fromLatin1("/qtc-test-settings-XXXXXX"));
|
||||
temporaryCleanSettingsDir.reset(new QTemporaryDir(settingsPathTemplate));
|
||||
temporaryCleanSettingsDir.reset(new Utils::TemporaryDirectory("qtc-test-settings"));
|
||||
if (!temporaryCleanSettingsDir->isValid())
|
||||
return 1;
|
||||
settingsPath = temporaryCleanSettingsDir->path();
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "clangcodemodelconnectionclient.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QProcess;
|
||||
class QTemporaryDir;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class Utf8String;
|
||||
|
||||
57
src/libs/utils/temporarydirectory.cpp
Normal file
57
src/libs/utils/temporarydirectory.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "temporarydirectory.h"
|
||||
|
||||
#include "qtcassert.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Utils {
|
||||
|
||||
static std::unique_ptr<QTemporaryDir> m_masterTemporaryDir;
|
||||
|
||||
TemporaryDirectory::TemporaryDirectory(const QString &pattern) :
|
||||
QTemporaryDir(m_masterTemporaryDir->path() + '/' + pattern)
|
||||
{
|
||||
QTC_CHECK(!QFileInfo(pattern).isAbsolute());
|
||||
}
|
||||
|
||||
QTemporaryDir *TemporaryDirectory::masterTemporaryDirectory()
|
||||
{
|
||||
return m_masterTemporaryDir.get();
|
||||
}
|
||||
|
||||
void TemporaryDirectory::setMasterTemporaryDirectory(const QString &pattern)
|
||||
{
|
||||
m_masterTemporaryDir = std::make_unique<QTemporaryDir>(pattern);
|
||||
}
|
||||
|
||||
QString TemporaryDirectory::masterDirectoryPath()
|
||||
{
|
||||
return m_masterTemporaryDir->path();
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
44
src/libs/utils/temporarydirectory.h
Normal file
44
src/libs/utils/temporarydirectory.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils_global.h"
|
||||
|
||||
#include <QTemporaryDir>
|
||||
|
||||
namespace Utils {
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT TemporaryDirectory : public QTemporaryDir
|
||||
{
|
||||
public:
|
||||
explicit TemporaryDirectory(const QString &pattern);
|
||||
|
||||
static QTemporaryDir *masterTemporaryDirectory();
|
||||
static void setMasterTemporaryDirectory(const QString &pattern);
|
||||
static QString masterDirectoryPath();
|
||||
};
|
||||
|
||||
} // namespace Utils
|
||||
39
src/libs/utils/temporaryfile.cpp
Normal file
39
src/libs/utils/temporaryfile.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "temporaryfile.h"
|
||||
|
||||
#include "temporarydirectory.h"
|
||||
#include "qtcassert.h"
|
||||
|
||||
namespace Utils {
|
||||
|
||||
TemporaryFile::TemporaryFile(const QString &pattern) :
|
||||
QTemporaryFile(TemporaryDirectory::masterTemporaryDirectory()->path() + '/' + pattern)
|
||||
{
|
||||
QTC_CHECK(!QFileInfo(pattern).isAbsolute());
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
40
src/libs/utils/temporaryfile.h
Normal file
40
src/libs/utils/temporaryfile.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils_global.h"
|
||||
|
||||
#include <QTemporaryFile>
|
||||
|
||||
namespace Utils {
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT TemporaryFile : public QTemporaryFile
|
||||
{
|
||||
public:
|
||||
explicit TemporaryFile(const QString &pattern);
|
||||
};
|
||||
|
||||
} // namespace Utils
|
||||
@@ -31,6 +31,8 @@ SOURCES += $$PWD/environment.cpp \
|
||||
$$PWD/settingsselector.cpp \
|
||||
$$PWD/stringutils.cpp \
|
||||
$$PWD/templateengine.cpp \
|
||||
$$PWD/temporarydirectory.cpp \
|
||||
$$PWD/temporaryfile.cpp \
|
||||
$$PWD/textfieldcheckbox.cpp \
|
||||
$$PWD/textfieldcombobox.cpp \
|
||||
$$PWD/filesearch.cpp \
|
||||
@@ -128,6 +130,8 @@ HEADERS += \
|
||||
$$PWD/shellcommandpage.h \
|
||||
$$PWD/stringutils.h \
|
||||
$$PWD/templateengine.h \
|
||||
$$PWD/temporarydirectory.h \
|
||||
$$PWD/temporaryfile.h \
|
||||
$$PWD/textfieldcheckbox.h \
|
||||
$$PWD/textfieldcombobox.h \
|
||||
$$PWD/filesearch.h \
|
||||
|
||||
@@ -214,6 +214,10 @@ Project {
|
||||
"synchronousprocess.h",
|
||||
"templateengine.cpp",
|
||||
"templateengine.h",
|
||||
"temporarydirectory.cpp",
|
||||
"temporarydirectory.h",
|
||||
"temporaryfile.cpp",
|
||||
"temporaryfile.h",
|
||||
"textfieldcheckbox.cpp",
|
||||
"textfieldcheckbox.h",
|
||||
"textfieldcombobox.cpp",
|
||||
|
||||
@@ -41,13 +41,13 @@
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/runextensions.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/temporaryfile.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QTime>
|
||||
#include <QTemporaryFile>
|
||||
#include <QTcpServer>
|
||||
#include <QTcpSocket>
|
||||
|
||||
@@ -495,7 +495,7 @@ void AndroidRunnerWorker::asyncStart(const QString &intentName,
|
||||
} else {
|
||||
// Handling ping.
|
||||
for (int i = 0; ; ++i) {
|
||||
QTemporaryFile tmp(QDir::tempPath() + "/pingpong");
|
||||
Utils::TemporaryFile tmp("pingpong");
|
||||
tmp.open();
|
||||
tmp.close();
|
||||
|
||||
@@ -563,7 +563,7 @@ void AndroidRunnerWorker::handleRemoteDebuggerRunning()
|
||||
m_socket->waitForBytesWritten();
|
||||
m_socket->close();
|
||||
} else {
|
||||
QTemporaryFile tmp(QDir::tempPath() + "/pingpong");
|
||||
Utils::TemporaryFile tmp("pingpong");
|
||||
tmp.open();
|
||||
|
||||
runAdb(selector() << "push" << tmp.fileName() << m_pongFile);
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
namespace CppTools { namespace Tests { class TemporaryCopiedDir; } }
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/runextensions.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
@@ -84,7 +85,8 @@ FormatTask format(FormatTask task)
|
||||
case Command::FileProcessing: {
|
||||
// Save text to temporary file
|
||||
const QFileInfo fi(task.filePath);
|
||||
Utils::TempFileSaver sourceFile(QDir::tempPath() + "/qtc_beautifier_XXXXXXXX."
|
||||
Utils::TempFileSaver sourceFile(Utils::TemporaryDirectory::masterDirectoryPath()
|
||||
+ "/qtc_beautifier_XXXXXXXX."
|
||||
+ fi.suffix());
|
||||
sourceFile.setAutoRemove(true);
|
||||
sourceFile.write(task.sourceData.toUtf8());
|
||||
|
||||
@@ -33,8 +33,7 @@
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
UiHeaderOnDiskManager::UiHeaderOnDiskManager()
|
||||
: m_temporaryDir(QDir::tempPath() + QStringLiteral("/qtc-clang-uiheader-XXXXXX"))
|
||||
UiHeaderOnDiskManager::UiHeaderOnDiskManager() : m_temporaryDir("/qtc-clang-uiheader-XXXXXX")
|
||||
{
|
||||
QTC_CHECK(m_temporaryDir.isValid());
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "refactoringconnectionclient.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
|
||||
@@ -55,9 +55,9 @@
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <QLoggingCategory>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
using namespace CppTools;
|
||||
using namespace ProjectExplorer;
|
||||
@@ -513,7 +513,7 @@ void ClangStaticAnalyzerRunControl::start()
|
||||
m_clangExecutable = executable;
|
||||
|
||||
// Create log dir
|
||||
QTemporaryDir temporaryDir(QDir::tempPath() + QLatin1String("/qtc-clangstaticanalyzer-XXXXXX"));
|
||||
Utils::TemporaryDirectory temporaryDir("qtc-clangstaticanalyzer-XXXXXX");
|
||||
temporaryDir.setAutoRemove(false);
|
||||
if (!temporaryDir.isValid()) {
|
||||
const QString errorMessage
|
||||
|
||||
@@ -29,12 +29,12 @@
|
||||
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/temporaryfile.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QLoggingCategory>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
static Q_LOGGING_CATEGORY(LOG, "qtc.clangstaticanalyzer.runner")
|
||||
|
||||
@@ -165,7 +165,7 @@ QString ClangStaticAnalyzerRunner::createLogFile(const QString &filePath) const
|
||||
const QString fileTemplate = m_clangLogFileDir
|
||||
+ QLatin1String("/report-") + fileName + QLatin1String("-XXXXXX.plist");
|
||||
|
||||
QTemporaryFile temporaryFile;
|
||||
Utils::TemporaryFile temporaryFile("clangstaticanalyzer");
|
||||
temporaryFile.setAutoRemove(false);
|
||||
temporaryFile.setFileTemplate(fileTemplate);
|
||||
if (temporaryFile.open()) {
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
|
||||
#include <QEventLoop>
|
||||
#include <QSignalSpy>
|
||||
#include <QTemporaryDir>
|
||||
#include <QTimer>
|
||||
#include <QtTest>
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
namespace CppTools { namespace Tests { class TemporaryCopiedDir; } }
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
#include <utils/parameteraction.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
@@ -85,7 +86,6 @@
|
||||
#include <QProcess>
|
||||
#include <QRegExp>
|
||||
#include <QSharedPointer>
|
||||
#include <QTemporaryFile>
|
||||
#include <QTextCodec>
|
||||
#include <QtPlugin>
|
||||
#include <QUrl>
|
||||
@@ -1119,8 +1119,8 @@ void ClearCasePlugin::diffActivity()
|
||||
diffGraphical(pair.first, pair.second);
|
||||
return;
|
||||
}
|
||||
rmdir(QDir::tempPath() + QLatin1String("/ccdiff/") + activity);
|
||||
QDir(QDir::tempPath()).rmpath(QLatin1String("ccdiff/") + activity);
|
||||
rmdir(Utils::TemporaryDirectory::masterDirectoryPath() + QLatin1String("/ccdiff/") + activity);
|
||||
QDir(Utils::TemporaryDirectory::masterDirectoryPath()).rmpath(QLatin1String("ccdiff/") + activity);
|
||||
m_diffPrefix = activity;
|
||||
const FileVerIt fend = filever.end();
|
||||
for (FileVerIt it = filever.begin(); it != fend; ++it) {
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QFile>
|
||||
@@ -62,7 +63,6 @@
|
||||
#include <QMessageBox>
|
||||
#include <QRegularExpression>
|
||||
#include <QSet>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
@@ -91,10 +91,9 @@ const Utils::FileName BuildDirManager::workDirectory() const
|
||||
if (bdir.exists())
|
||||
return bdir;
|
||||
if (!m_tempDir) {
|
||||
const QString path = QDir::tempPath() + QLatin1String("/qtc-cmake-XXXXXX");
|
||||
m_tempDir.reset(new QTemporaryDir(path));
|
||||
m_tempDir.reset(new Utils::TemporaryDirectory("qtc-cmake-XXXXXXXX"));
|
||||
if (!m_tempDir->isValid())
|
||||
emit errorOccured(tr("Failed to create temporary directory using template \"%1\".").arg(path));
|
||||
emit errorOccured(tr("Failed to create temporary directory \"%1\".").arg(m_tempDir->path()));
|
||||
}
|
||||
return Utils::FileName::fromString(m_tempDir->path());
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
#include "cmakeconfigitem.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QTemporaryDir>
|
||||
#include <QTimer>
|
||||
|
||||
#include <functional>
|
||||
@@ -104,7 +104,7 @@ private:
|
||||
void becameDirty();
|
||||
|
||||
CMakeBuildConfiguration *m_buildConfiguration = nullptr;
|
||||
mutable std::unique_ptr<QTemporaryDir> m_tempDir = nullptr;
|
||||
mutable std::unique_ptr<Utils::TemporaryDirectory> m_tempDir = nullptr;
|
||||
mutable CMakeConfig m_cmakeCache;
|
||||
|
||||
QTimer m_reparseTimer;
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QCryptographicHash>
|
||||
#include <QFile>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QLocalSocket>
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
#include <QLoggingCategory>
|
||||
#include <QTemporaryDir>
|
||||
#include <QTimer>
|
||||
#include <QVariantMap>
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
#include <QSet>
|
||||
#include <QTemporaryDir>
|
||||
#include <QTimer>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -46,12 +46,12 @@
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
#include <texteditor/texteditor.h>
|
||||
#include <texteditor/textdocument.h>
|
||||
|
||||
#include <QtPlugin>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
@@ -335,7 +335,7 @@ static inline QString filePrefixFromTitle(const QString &title)
|
||||
static inline QString tempFilePattern(const QString &prefix, const QString &extension)
|
||||
{
|
||||
// Get directory
|
||||
QString pattern = QDir::tempPath();
|
||||
QString pattern = Utils::TemporaryDirectory::masterDirectoryPath();
|
||||
const QChar slash = QLatin1Char('/');
|
||||
if (!pattern.endsWith(slash))
|
||||
pattern.append(slash);
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <QSettings>
|
||||
#include <QCoreApplication>
|
||||
|
||||
@@ -39,7 +40,7 @@ static const char displayCountKeyC[] = "DisplayCount";
|
||||
namespace CodePaster {
|
||||
|
||||
FileShareProtocolSettings::FileShareProtocolSettings() :
|
||||
path(QDir::tempPath()), displayCount(10)
|
||||
path(Utils::TemporaryDirectory::masterDirectoryPath()), displayCount(10)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -42,9 +42,9 @@
|
||||
#include <cplusplus/LookupContext.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/runextensions.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QElapsedTimer>
|
||||
#include <QRegularExpression>
|
||||
|
||||
@@ -72,10 +72,9 @@ public:
|
||||
WriteTaskFileForDiagnostics()
|
||||
: m_processedDiagnostics(0)
|
||||
{
|
||||
const QString fileName = QDir::tempPath()
|
||||
+ QLatin1String("/qtc_findErrorsIndexing.diagnostics.")
|
||||
+ QDateTime::currentDateTime().toString(QLatin1String("yyMMdd_HHmm"))
|
||||
+ QLatin1String(".tasks");
|
||||
const QString fileName = Utils::TemporaryDirectory::masterDirectoryPath()
|
||||
+ "/qtc_findErrorsIndexing.diagnostics."
|
||||
+ QDateTime::currentDateTime().toString("yyMMdd_HHmm") + ".tasks";
|
||||
|
||||
m_file.setFileName(fileName);
|
||||
Q_ASSERT(m_file.open(QIODevice::WriteOnly | QIODevice::Text));
|
||||
|
||||
@@ -29,10 +29,10 @@
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <QtTest>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
|
||||
/*!
|
||||
Tests for various parts of the code generation. Well, okay, currently it only
|
||||
@@ -527,7 +527,7 @@ void CppToolsPlugin::test_codegen_definition_middle_member()
|
||||
"\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"int y;\n").arg(QDir::tempPath()).toLatin1();
|
||||
"int y;\n").arg(Utils::TemporaryDirectory::masterDirectoryPath()).toLatin1();
|
||||
|
||||
Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 4U);
|
||||
QVERIFY(sourceDocument);
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <cpptools/cppprojectfile.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <cplusplus/CppDocument.h>
|
||||
#include <cplusplus/Token.h>
|
||||
@@ -445,9 +446,10 @@ Dumper::Dumper(const CPlusPlus::Snapshot &globalSnapshot, const QString &logFile
|
||||
QString logFileId_ = logFileId;
|
||||
if (!logFileId_.isEmpty())
|
||||
logFileId_.prepend(QLatin1Char('_'));
|
||||
const QString logFileName = QDir::tempPath() + QString::fromLatin1("/qtc-codemodelinspection")
|
||||
const QString logFileName = ::Utils::TemporaryDirectory::masterDirectoryPath()
|
||||
+ "/qtc-codemodelinspection"
|
||||
+ ideRevision_
|
||||
+ QDateTime::currentDateTime().toString(QLatin1String("_yyMMdd_hhmmss"))
|
||||
+ QDateTime::currentDateTime().toString("_yyMMdd_hhmmss")
|
||||
+ logFileId_
|
||||
+ QLatin1String(".txt");
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "cppfilesettingspage.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QtTest>
|
||||
@@ -45,7 +46,7 @@ static void createTempFile(const QString &fileName)
|
||||
|
||||
static QString baseTestDir()
|
||||
{
|
||||
return QDir::tempPath() + _("/qtc_cppheadersource/");
|
||||
return Utils::TemporaryDirectory::masterDirectoryPath() + "/qtc_cppheadersource/";
|
||||
}
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <cplusplus/CppDocument.h>
|
||||
#include <utils/executeondestruction.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
@@ -83,7 +84,7 @@ QString TestDocument::filePath() const
|
||||
return QDir::cleanPath(m_baseDirectory + QLatin1Char('/') + m_fileName);
|
||||
|
||||
if (!QFileInfo(m_fileName).isAbsolute())
|
||||
return QDir::tempPath() + QLatin1Char('/') + m_fileName;
|
||||
return Utils::TemporaryDirectory::masterDirectoryPath() + '/' + m_fileName;
|
||||
|
||||
return m_fileName;
|
||||
}
|
||||
@@ -301,8 +302,8 @@ ProjectInfo ProjectOpenerAndCloser::open(const QString &projectFile, bool config
|
||||
}
|
||||
|
||||
TemporaryDir::TemporaryDir()
|
||||
: m_temporaryDir(QFileInfo(QDir::tempPath()).canonicalFilePath()
|
||||
+ QLatin1String("/qtcreator-tests-XXXXXX"))
|
||||
: m_temporaryDir(QFileInfo(Utils::TemporaryDirectory::masterDirectoryPath()).canonicalFilePath()
|
||||
+ "/qtcreator-tests-XXXXXX")
|
||||
, m_isValid(m_temporaryDir.isValid())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@
|
||||
#include "cpptools_global.h"
|
||||
|
||||
#include <cplusplus/CppDocument.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <QStringList>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
namespace CPlusPlus {
|
||||
class Document;
|
||||
@@ -138,7 +138,7 @@ public:
|
||||
QString createFile(const QByteArray &relativePath, const QByteArray &contents);
|
||||
|
||||
protected:
|
||||
QTemporaryDir m_temporaryDir;
|
||||
Utils::TemporaryDirectory m_temporaryDir;
|
||||
bool m_isValid;
|
||||
};
|
||||
|
||||
|
||||
@@ -2743,7 +2743,7 @@ void DebuggerPluginPrivate::updateDebugWithoutDeployMenu()
|
||||
void DebuggerPluginPrivate::dumpLog()
|
||||
{
|
||||
QString fileName = QFileDialog::getSaveFileName(ICore::mainWindow(),
|
||||
tr("Save Debugger Log"), QDir::tempPath());
|
||||
tr("Save Debugger Log"), Utils::TemporaryDirectory::masterDirectoryPath());
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
FileSaver saver(fileName);
|
||||
|
||||
@@ -34,9 +34,10 @@
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
#include <utils/temporaryfile.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
using namespace Utils;
|
||||
using namespace ProjectExplorer;
|
||||
@@ -277,8 +278,7 @@ void GdbCoreEngine::shutdownEngine()
|
||||
|
||||
static QString tempCoreFilename()
|
||||
{
|
||||
QString pattern = QDir::tempPath() + QLatin1String("/tmpcore-XXXXXX");
|
||||
QTemporaryFile tmp(pattern);
|
||||
Utils::TemporaryFile tmp("tmpcore-XXXXXX");
|
||||
tmp.open();
|
||||
return tmp.fileName();
|
||||
}
|
||||
@@ -292,7 +292,7 @@ void GdbCoreEngine::unpackCoreIfNeeded()
|
||||
showMessage(msg.arg(m_tempCoreName));
|
||||
arguments << QLatin1String("-o") << m_tempCoreName << QLatin1String("-x") << m_coreName;
|
||||
m_coreUnpackProcess = new QProcess(this);
|
||||
m_coreUnpackProcess->setWorkingDirectory(QDir::tempPath());
|
||||
m_coreUnpackProcess->setWorkingDirectory(Utils::TemporaryDirectory::masterDirectoryPath());
|
||||
m_coreUnpackProcess->start(QLatin1String("lzop"), arguments);
|
||||
connect(m_coreUnpackProcess, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
|
||||
this, &GdbCoreEngine::continueSetupEngine);
|
||||
@@ -303,7 +303,7 @@ void GdbCoreEngine::unpackCoreIfNeeded()
|
||||
m_tempCoreFile.open(QFile::WriteOnly);
|
||||
arguments << QLatin1String("-c") << QLatin1String("-d") << m_coreName;
|
||||
m_coreUnpackProcess = new QProcess(this);
|
||||
m_coreUnpackProcess->setWorkingDirectory(QDir::tempPath());
|
||||
m_coreUnpackProcess->setWorkingDirectory(Utils::TemporaryDirectory::masterDirectoryPath());
|
||||
m_coreUnpackProcess->start(QLatin1String("gzip"), arguments);
|
||||
connect(m_coreUnpackProcess, &QProcess::readyRead, this, &GdbCoreEngine::writeCoreChunk);
|
||||
connect(m_coreUnpackProcess, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
|
||||
|
||||
@@ -71,13 +71,13 @@
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/savedaction.h>
|
||||
#include <utils/temporaryfile.h>
|
||||
|
||||
#include <QBuffer>
|
||||
#include <QDirIterator>
|
||||
#include <QMessageBox>
|
||||
#include <QProcess>
|
||||
#include <QPushButton>
|
||||
#include <QTemporaryFile>
|
||||
#include <QJsonArray>
|
||||
|
||||
using namespace Core;
|
||||
@@ -2999,7 +2999,7 @@ static void handleShowModuleSymbols(const DebuggerResponse &response,
|
||||
|
||||
void GdbEngine::requestModuleSymbols(const QString &modulePath)
|
||||
{
|
||||
QTemporaryFile tf(QDir::tempPath() + "/gdbsymbols");
|
||||
Utils::TemporaryFile tf("gdbsymbols");
|
||||
if (!tf.open())
|
||||
return;
|
||||
QString fileName = tf.fileName();
|
||||
@@ -3351,7 +3351,7 @@ void GdbEngine::handleThreadNames(const DebuggerResponse &response)
|
||||
void GdbEngine::createSnapshot()
|
||||
{
|
||||
QString fileName;
|
||||
QTemporaryFile tf(QDir::tempPath() + "/gdbsnapshot");
|
||||
Utils::TemporaryFile tf("gdbsnapshot");
|
||||
if (tf.open()) {
|
||||
fileName = tf.fileName();
|
||||
tf.close();
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
|
||||
#include <utils/temporaryfile.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QLabel>
|
||||
#include <QMenu>
|
||||
@@ -41,7 +43,6 @@
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
#include <QDir>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
// Widget showing the image in a 1-pixel frame with context menu.
|
||||
class ImageWidget : public QWidget
|
||||
@@ -131,12 +132,9 @@ void ImageViewer::clicked(const QString &message)
|
||||
// Open Qt Creator's image viewer
|
||||
static void openImageViewer(const QImage &image)
|
||||
{
|
||||
QString fileName = QDir::tempPath();
|
||||
if (!fileName.endsWith(QLatin1Char('/')))
|
||||
fileName += QLatin1Char('/');
|
||||
fileName += QLatin1String("qtcreatorXXXXXX.png");
|
||||
QString fileName;
|
||||
{
|
||||
QTemporaryFile temporaryFile(fileName);
|
||||
Utils::TemporaryFile temporaryFile("qtcreatorXXXXXX.png");
|
||||
temporaryFile.setAutoRemove(false);
|
||||
image.save(&temporaryFile);
|
||||
fileName = temporaryFile.fileName();
|
||||
|
||||
@@ -35,12 +35,12 @@
|
||||
#include <ssh/sftpfilesystemmodel.h>
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/temporaryfile.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QRegExp>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QFormLayout>
|
||||
@@ -184,7 +184,7 @@ void SelectRemoteFileDialog::selectFile()
|
||||
this, &SelectRemoteFileDialog::handleSftpOperationFinished);
|
||||
|
||||
{
|
||||
QTemporaryFile localFile(QDir::tempPath() + QLatin1String("/remotecore-XXXXXX"));
|
||||
Utils::TemporaryFile localFile("remotecore-XXXXXX");
|
||||
localFile.open();
|
||||
m_localFile = localFile.fileName();
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#else
|
||||
#include <utils/temporaryfile.h>
|
||||
|
||||
#include <QSocketNotifier>
|
||||
#include <QTemporaryFile>
|
||||
#include <QVarLengthArray>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
@@ -85,7 +85,7 @@ bool OutputCollector::listen()
|
||||
QByteArray codedServerPath;
|
||||
forever {
|
||||
{
|
||||
QTemporaryFile tf;
|
||||
Utils::TemporaryFile tf("outputcollector");
|
||||
if (!tf.open()) {
|
||||
m_errorString = tr("Cannot create temporary file: %1").arg(tf.errorString());
|
||||
m_serverPath.clear();
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/checkablemessagebox.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include "symbolpathsdialog.h"
|
||||
|
||||
@@ -139,7 +140,7 @@ CdbSymbolPathListEditor::CdbSymbolPathListEditor(QWidget *parent) :
|
||||
bool CdbSymbolPathListEditor::promptCacheDirectory(QWidget *parent, QString *cacheDirectory)
|
||||
{
|
||||
CacheDirectoryDialog dialog(parent);
|
||||
dialog.setPath(QDir::tempPath() + QDir::separator() + QLatin1String("symbolcache"));
|
||||
dialog.setPath(Utils::TemporaryDirectory::masterDirectoryPath() + "/symbolcache");
|
||||
if (dialog.exec() != QDialog::Accepted)
|
||||
return false;
|
||||
*cacheDirectory = dialog.path();
|
||||
@@ -165,7 +166,7 @@ void CdbSymbolPathListEditor::setupSymbolPaths()
|
||||
if (path.isEmpty() && indexOfSymbolCache != -1)
|
||||
path = currentPaths.at(indexOfSymbolCache);
|
||||
if (path.isEmpty())
|
||||
path = QDir::tempPath() + QDir::separator() + QLatin1String("symbolcache");
|
||||
path = Utils::TemporaryDirectory::masterDirectoryPath() + "/symbolcache";
|
||||
|
||||
bool useSymbolServer = true;
|
||||
bool useSymbolCache = true;
|
||||
|
||||
@@ -40,11 +40,11 @@
|
||||
|
||||
#include <utils/progressindicator.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/temporaryfile.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QTemporaryFile>
|
||||
#include <QTextCodec>
|
||||
|
||||
using namespace Core;
|
||||
@@ -169,7 +169,7 @@ void DiffEditorWidgetController::patch(bool revert)
|
||||
if (!textDocument)
|
||||
return;
|
||||
|
||||
QTemporaryFile contentsCopy;
|
||||
Utils::TemporaryFile contentsCopy("diff");
|
||||
if (!contentsCopy.open())
|
||||
return;
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@
|
||||
#include <QAction>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QTemporaryFile>
|
||||
#include <QDir>
|
||||
#include <QMap>
|
||||
#include <QFutureWatcher>
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/temporaryfile.h>
|
||||
|
||||
#include <vcsbase/submitfilemodel.h>
|
||||
#include <vcsbase/vcsbaseeditor.h>
|
||||
@@ -72,7 +73,6 @@
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QRegExp>
|
||||
#include <QTemporaryFile>
|
||||
#include <QTextCodec>
|
||||
#include <QToolButton>
|
||||
|
||||
@@ -687,7 +687,7 @@ void GitClient::slotUnstageChunk()
|
||||
|
||||
void GitClient::stage(const QString &patch, bool revert)
|
||||
{
|
||||
QTemporaryFile patchFile;
|
||||
Utils::TemporaryFile patchFile("git-patchfile");
|
||||
if (!patchFile.open())
|
||||
return;
|
||||
|
||||
|
||||
@@ -38,12 +38,13 @@
|
||||
#include <vcsbase/vcsoutputwindow.h>
|
||||
#include <texteditor/textdocument.h>
|
||||
|
||||
#include <utils/temporaryfile.h>
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QRegExp>
|
||||
#include <QSet>
|
||||
#include <QTemporaryFile>
|
||||
#include <QTextCodec>
|
||||
#include <QDir>
|
||||
|
||||
@@ -217,7 +218,7 @@ void GitEditorWidget::logChange()
|
||||
|
||||
void GitEditorWidget::applyDiffChunk(const DiffChunk& chunk, bool revert)
|
||||
{
|
||||
QTemporaryFile patchFile;
|
||||
Utils::TemporaryFile patchFile("git-apply-chunk");
|
||||
if (!patchFile.open())
|
||||
return;
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QStringBuilder>
|
||||
#include <QDir>
|
||||
#include <QUrl>
|
||||
|
||||
#include <QApplication>
|
||||
@@ -135,7 +135,7 @@ bool HelpViewer::launchWithExternalApp(const QUrl &url)
|
||||
|
||||
const QString& path = resolvedUrl.path();
|
||||
if (!canOpenPage(path)) {
|
||||
Utils::TempFileSaver saver(QDir::tempPath()
|
||||
Utils::TempFileSaver saver(Utils::TemporaryDirectory::masterDirectoryPath()
|
||||
+ "/qtchelp_XXXXXX." + QFileInfo(path).completeSuffix());
|
||||
saver.setAutoRemove(false);
|
||||
if (!saver.hasError())
|
||||
|
||||
@@ -42,8 +42,9 @@
|
||||
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
|
||||
#include <utils/temporaryfile.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QTemporaryFile>
|
||||
#include <QFile>
|
||||
#include <QSettings>
|
||||
|
||||
@@ -275,7 +276,7 @@ void IosDeployStep::checkProvisioningProfile()
|
||||
return;
|
||||
end += 8;
|
||||
|
||||
QTemporaryFile f;
|
||||
Utils::TemporaryFile f("iosdeploy");
|
||||
if (!f.open())
|
||||
return;
|
||||
f.write(provisionData.mid(start, end - start));
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <utils/fileutils.h>
|
||||
#include "utils/runextensions.h"
|
||||
#include "utils/synchronousprocess.h"
|
||||
#include "utils/temporaryfile.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
@@ -50,7 +51,6 @@
|
||||
#include <QProcessEnvironment>
|
||||
#include <QScopedArrayPointer>
|
||||
#include <QSocketNotifier>
|
||||
#include <QTemporaryFile>
|
||||
#include <QTimer>
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
@@ -81,8 +81,8 @@ class LogTailFiles : public QObject
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
void exec(QFutureInterface<void> &fi, std::shared_ptr<QTemporaryFile> stdoutFile,
|
||||
std::shared_ptr<QTemporaryFile> stderrFile)
|
||||
void exec(QFutureInterface<void> &fi, std::shared_ptr<Utils::TemporaryFile> stdoutFile,
|
||||
std::shared_ptr<Utils::TemporaryFile> stderrFile)
|
||||
{
|
||||
if (fi.isCanceled())
|
||||
return;
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
watcher.setFuture(fi.future());
|
||||
|
||||
// Process to print the console output while app is running.
|
||||
auto logProcess = [this, fi](QProcess *tailProcess, std::shared_ptr<QTemporaryFile> file) {
|
||||
auto logProcess = [this, fi](QProcess *tailProcess, std::shared_ptr<Utils::TemporaryFile> file) {
|
||||
QObject::connect(tailProcess, &QProcess::readyReadStandardOutput, [=]() {
|
||||
if (!fi.isCanceled())
|
||||
emit logMessage(QString::fromLocal8Bit(tailProcess->readAll()));
|
||||
@@ -910,16 +910,13 @@ void IosSimulatorToolHandlerPrivate::launchAppOnSimulator(const QStringList &ext
|
||||
const QString bundleId = SimulatorControl::bundleIdentifier(appBundle);
|
||||
const bool debugRun = runKind == IosToolHandler::DebugRun;
|
||||
bool captureConsole = IosConfigurations::xcodeVersion() >= QVersionNumber(8);
|
||||
std::shared_ptr<QTemporaryFile> stdoutFile;
|
||||
std::shared_ptr<QTemporaryFile> stderrFile;
|
||||
std::shared_ptr<Utils::TemporaryFile> stdoutFile;
|
||||
std::shared_ptr<Utils::TemporaryFile> stderrFile;
|
||||
|
||||
if (captureConsole) {
|
||||
const QString fileTemplate = CONSOLE_PATH_TEMPLATE.arg(deviceId).arg(bundleId);
|
||||
stdoutFile.reset(new QTemporaryFile);
|
||||
stdoutFile->setFileTemplate(fileTemplate + QStringLiteral(".stdout"));
|
||||
|
||||
stderrFile.reset(new QTemporaryFile);
|
||||
stderrFile->setFileTemplate(fileTemplate + QStringLiteral(".stderr"));
|
||||
stdoutFile.reset(new Utils::TemporaryFile(fileTemplate + ".stdout"));
|
||||
stderrFile.reset(new Utils::TemporaryFile(fileTemplate + ".stderr"));
|
||||
|
||||
captureConsole = stdoutFile->open() && stderrFile->open();
|
||||
if (!captureConsole)
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include <utils/parameteraction.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
#include <vcsbase/basevcseditorfactory.h>
|
||||
#include <vcsbase/basevcssubmiteditorfactory.h>
|
||||
#include <vcsbase/vcsbaseeditor.h>
|
||||
@@ -934,11 +935,7 @@ PerforcePlugin::createTemporaryArgumentFile(const QStringList &extraArgs,
|
||||
// create pattern
|
||||
QString pattern = m_instance->m_tempFilePattern;
|
||||
if (pattern.isEmpty()) {
|
||||
pattern = QDir::tempPath();
|
||||
const QChar slash = QLatin1Char('/');
|
||||
if (!pattern.endsWith(slash))
|
||||
pattern += slash;
|
||||
pattern += QLatin1String("qtc_p4_XXXXXX.args");
|
||||
pattern = Utils::TemporaryDirectory::masterDirectoryPath() + "/qtc_p4_XXXXXX.args";
|
||||
m_instance->m_tempFilePattern = pattern;
|
||||
}
|
||||
QSharedPointer<TempFileSaver> rc(new TempFileSaver(pattern));
|
||||
|
||||
@@ -33,10 +33,10 @@
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QSysInfo>
|
||||
#include <QTemporaryFile>
|
||||
#include <QTextCodec>
|
||||
|
||||
enum { debug = 0 };
|
||||
@@ -261,11 +261,9 @@ bool AbstractMsvcToolChain::generateEnvironmentSettings(const Utils::Environment
|
||||
const QString marker = "####################";
|
||||
// Create a temporary file name for the output. Use a temporary file here
|
||||
// as I don't know another way to do this in Qt...
|
||||
// Note, can't just use a QTemporaryFile all the way through as it remains open
|
||||
// internally so it can't be streamed to later.
|
||||
|
||||
// Create a batch file to create and save the env settings
|
||||
Utils::TempFileSaver saver(QDir::tempPath() + QLatin1String("/XXXXXX.bat"));
|
||||
Utils::TempFileSaver saver(Utils::TemporaryDirectory::masterDirectoryPath() + "/XXXXXX.bat");
|
||||
|
||||
QByteArray call = "call ";
|
||||
call += Utils::QtcProcess::quoteArg(batchFile).toLocal8Bit();
|
||||
|
||||
@@ -32,17 +32,17 @@
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/macroexpander.h>
|
||||
#include <utils/templateengine.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
#include <utils/temporaryfile.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDate>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QIcon>
|
||||
#include <QJSEngine>
|
||||
#include <QTemporaryFile>
|
||||
#include <QTime>
|
||||
#include <QXmlStreamAttribute>
|
||||
#include <QXmlStreamReader>
|
||||
@@ -853,16 +853,12 @@ private:
|
||||
};
|
||||
|
||||
TemporaryFileTransform::TemporaryFileTransform(TemporaryFilePtrList *f) :
|
||||
m_files(f), m_pattern(QDir::tempPath())
|
||||
{
|
||||
if (!m_pattern.endsWith(QLatin1Char('/')))
|
||||
m_pattern += QLatin1Char('/');
|
||||
m_pattern += QLatin1String("qtcreatorXXXXXX.txt");
|
||||
}
|
||||
m_files(f), m_pattern(Utils::TemporaryDirectory::masterDirectoryPath() + "/qtcreatorXXXXXX.txt")
|
||||
{ }
|
||||
|
||||
QString TemporaryFileTransform::operator()(const QString &value) const
|
||||
{
|
||||
TemporaryFilePtr temporaryFile(new QTemporaryFile(m_pattern));
|
||||
TemporaryFilePtr temporaryFile(new Utils::TemporaryFile(m_pattern));
|
||||
QTC_ASSERT(temporaryFile->open(), return QString());
|
||||
|
||||
temporaryFile->write(value.toLocal8Bit());
|
||||
|
||||
@@ -34,10 +34,11 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QIODevice;
|
||||
class QDebug;
|
||||
class QTemporaryFile;
|
||||
class QJSEngine;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils { class TemporaryFile; }
|
||||
|
||||
namespace ProjectExplorer {
|
||||
namespace Internal {
|
||||
|
||||
@@ -136,7 +137,7 @@ public:
|
||||
class CustomWizardContext {
|
||||
public:
|
||||
typedef QMap<QString, QString> FieldReplacementMap;
|
||||
typedef QSharedPointer<QTemporaryFile> TemporaryFilePtr;
|
||||
typedef QSharedPointer<Utils::TemporaryFile> TemporaryFilePtr;
|
||||
typedef QList<TemporaryFilePtr> TemporaryFilePtrList;
|
||||
|
||||
void reset();
|
||||
|
||||
@@ -29,11 +29,10 @@
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QDebug>
|
||||
#include <QTemporaryFile>
|
||||
#include <QSharedPointer>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
@@ -147,8 +146,8 @@ Core::GeneratedFiles
|
||||
{
|
||||
// Run in temporary directory as the target path may not exist yet.
|
||||
QString stdOut;
|
||||
if (!runGenerationScriptHelper(QDir::tempPath(), script, arguments, true,
|
||||
fieldMap, &stdOut, errorMessage))
|
||||
if (!runGenerationScriptHelper(Utils::TemporaryDirectory::masterDirectoryPath(),
|
||||
script, arguments, true, fieldMap, &stdOut, errorMessage))
|
||||
return Core::GeneratedFiles();
|
||||
Core::GeneratedFiles files;
|
||||
// Parse the output consisting of lines with ',' separated tokens.
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "task.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
@@ -501,18 +502,14 @@ void ProjectExplorerPlugin::testGnuMakeParserTaskMangling()
|
||||
QFETCH(Task, outputTask);
|
||||
|
||||
// setup files:
|
||||
QString tempdir = QDir::tempPath();
|
||||
const QChar slash = QLatin1Char('/');
|
||||
tempdir.append(slash);
|
||||
tempdir.append(QUuid::createUuid().toString());
|
||||
tempdir.append(slash);
|
||||
|
||||
const QString tempdir
|
||||
= Utils::TemporaryDirectory::masterDirectoryPath() + '/' + QUuid::createUuid().toString() + '/';
|
||||
QDir filedir(tempdir);
|
||||
foreach (const QString &file, files) {
|
||||
Q_ASSERT(!file.startsWith(slash));
|
||||
Q_ASSERT(!file.contains(QLatin1String("../")));
|
||||
Q_ASSERT(!file.startsWith('/'));
|
||||
Q_ASSERT(!file.contains("../"));
|
||||
|
||||
filedir.mkpath(file.left(file.lastIndexOf(slash)));
|
||||
filedir.mkpath(file.left(file.lastIndexOf('/')));
|
||||
|
||||
QFile tempfile(tempdir + file);
|
||||
if (!tempfile.open(QIODevice::WriteOnly))
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <utils/winutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
@@ -318,7 +319,7 @@ QByteArray MsvcToolChain::msvcPredefinedMacros(const QStringList cxxflags,
|
||||
}
|
||||
}
|
||||
|
||||
Utils::TempFileSaver saver(QDir::tempPath() + QLatin1String("/envtestXXXXXX.cpp"));
|
||||
Utils::TempFileSaver saver(Utils::TemporaryDirectory::masterDirectoryPath() + "/envtestXXXXXX.cpp");
|
||||
saver.write(msvcCompilationFile());
|
||||
if (!saver.finalize()) {
|
||||
qWarning("%s: %s", Q_FUNC_INFO, qPrintable(saver.errorString()));
|
||||
@@ -326,7 +327,7 @@ QByteArray MsvcToolChain::msvcPredefinedMacros(const QStringList cxxflags,
|
||||
}
|
||||
Utils::SynchronousProcess cpp;
|
||||
cpp.setEnvironment(env.toStringList());
|
||||
cpp.setWorkingDirectory(QDir::tempPath());
|
||||
cpp.setWorkingDirectory(Utils::TemporaryDirectory::masterDirectoryPath());
|
||||
QStringList arguments;
|
||||
const Utils::FileName binary = env.searchInPath(QLatin1String("cl.exe"));
|
||||
if (binary.isEmpty()) {
|
||||
|
||||
@@ -48,9 +48,9 @@
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/environment.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <QProcess>
|
||||
#include <QTemporaryDir>
|
||||
#include <QCoreApplication>
|
||||
#include <QCryptographicHash>
|
||||
#include <QDateTime>
|
||||
@@ -243,7 +243,7 @@ bool PuppetCreator::build(const QString &qmlPuppetProjectFilePath) const
|
||||
|
||||
m_compileLog.clear();
|
||||
|
||||
QTemporaryDir buildDirectory;
|
||||
Utils::TemporaryDirectory buildDirectory("qml-puppet-build");
|
||||
|
||||
bool buildSucceeded = false;
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#include <qmldebug/qmldebugcommandlinearguments.h>
|
||||
#include <debugger/analyzer/analyzerruncontrol.h>
|
||||
|
||||
#include <utils/temporaryfile.h>
|
||||
|
||||
#include <QTcpServer>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
@@ -43,7 +45,7 @@ namespace QmlProfiler {
|
||||
|
||||
QString LocalQmlProfilerRunner::findFreeSocket()
|
||||
{
|
||||
QTemporaryFile file;
|
||||
Utils::TemporaryFile file("qmlprofiler-freesocket");
|
||||
if (file.open()) {
|
||||
return file.fileName();
|
||||
} else {
|
||||
|
||||
@@ -31,10 +31,11 @@
|
||||
#include "qmltypedevent.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/temporaryfile.h>
|
||||
|
||||
#include <QUrl>
|
||||
#include <QDebug>
|
||||
#include <QStack>
|
||||
#include <QTemporaryFile>
|
||||
#include <algorithm>
|
||||
|
||||
namespace QmlProfiler {
|
||||
@@ -42,6 +43,7 @@ namespace QmlProfiler {
|
||||
class QmlProfilerDataModel::QmlProfilerDataModelPrivate
|
||||
{
|
||||
public:
|
||||
QmlProfilerDataModelPrivate() : file("qmlprofiler-data") { }
|
||||
void rewriteType(int typeIndex);
|
||||
int resolveStackTop();
|
||||
|
||||
@@ -51,7 +53,7 @@ public:
|
||||
int modelId;
|
||||
Internal::QmlProfilerDetailsRewriter *detailsRewriter;
|
||||
|
||||
QTemporaryFile file;
|
||||
Utils::TemporaryFile file;
|
||||
QDataStream eventStream;
|
||||
};
|
||||
|
||||
|
||||
@@ -28,12 +28,12 @@
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/temporaryfile.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QDomDocument>
|
||||
#include <QProcess>
|
||||
#include <QStandardPaths>
|
||||
#include <QTemporaryFile>
|
||||
#include <QApplication>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
@@ -100,9 +100,8 @@ QList<Utils::EnvironmentItem> QnxUtils::qnxEnvironmentFromEnvFile(const QString
|
||||
const bool isWindows = Utils::HostOsInfo::isWindowsHost();
|
||||
|
||||
// locking creating bbndk-env file wrapper script
|
||||
QTemporaryFile tmpFile(
|
||||
QDir::tempPath() + QLatin1Char('/')
|
||||
+ QLatin1String("bbndk-env-eval-XXXXXX") + QLatin1String(isWindows ? ".bat" : ".sh"));
|
||||
Utils::TemporaryFile tmpFile(QString::fromLatin1("bbndk-env-eval-XXXXXX")
|
||||
+ QString::fromLatin1(isWindows ? ".bat" : ".sh"));
|
||||
if (!tmpFile.open())
|
||||
return items;
|
||||
tmpFile.setTextModeEnabled(true);
|
||||
|
||||
@@ -44,7 +44,8 @@ static const char TaskCategory[] = "Task.Category.ExtraCompiler.QScxmlc";
|
||||
QScxmlcGenerator::QScxmlcGenerator(const Project *project,
|
||||
const Utils::FileName &source,
|
||||
const Utils::FileNameList &targets, QObject *parent) :
|
||||
ProcessExtraCompiler(project, source, targets, parent)
|
||||
ProcessExtraCompiler(project, source, targets, parent),
|
||||
m_tmpdir("qscxmlgenerator")
|
||||
{
|
||||
QTC_ASSERT(targets.count() == 2, return);
|
||||
m_header = m_tmpdir.path() + QLatin1Char('/') + targets[0].fileName();
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
|
||||
#include <projectexplorer/extracompiler.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <QProcess>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
namespace QtSupport {
|
||||
|
||||
@@ -51,7 +51,7 @@ private:
|
||||
bool prepareToRun(const QByteArray &sourceContents) override;
|
||||
QList<ProjectExplorer::Task> parseIssues(const QByteArray &processStderr) override;
|
||||
|
||||
QTemporaryDir m_tmpdir;
|
||||
Utils::TemporaryDirectory m_tmpdir;
|
||||
QString m_header;
|
||||
QString m_impl;
|
||||
};
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QList>
|
||||
@@ -364,8 +365,8 @@ void QtSupportPlugin::testQtProjectImporter_oneProject()
|
||||
BaseQtVersion *defaultQt = QtKitInformation::qtVersion(defaultKit);
|
||||
QVERIFY(defaultQt);
|
||||
|
||||
const QTemporaryDir tempDir1;
|
||||
const QTemporaryDir tempDir2;
|
||||
const Utils::TemporaryDirectory tempDir1("tmp1");
|
||||
const Utils::TemporaryDirectory tempDir2("tmp2");
|
||||
|
||||
const QString appDir = QCoreApplication::applicationDirPath();
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#include <utils/reloadpromptutils.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QTemporaryFile>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <qdebug.h>
|
||||
|
||||
@@ -54,7 +54,6 @@
|
||||
#include <QtPlugin>
|
||||
#include <QAction>
|
||||
#include <QDir>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
using namespace Core;
|
||||
|
||||
|
||||
@@ -31,10 +31,9 @@
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/temporaryfile.h>
|
||||
#include <ssh/sftpchannel.h>
|
||||
|
||||
#include <QTemporaryFile>
|
||||
|
||||
#define CALLGRIND_CONTROL_DEBUG 0
|
||||
|
||||
const QLatin1String CALLGRIND_CONTROL_BINARY("callgrind_control");
|
||||
@@ -228,7 +227,7 @@ void CallgrindController::foundRemoteFile()
|
||||
void CallgrindController::sftpInitialized()
|
||||
{
|
||||
cleanupTempFile();
|
||||
QTemporaryFile dataFile(QDir::tempPath() + QLatin1Char('/') + QLatin1String("callgrind.out."));
|
||||
Utils::TemporaryFile dataFile("callgrind.out.");
|
||||
QTC_ASSERT(dataFile.open(), return);
|
||||
m_tempDataFile = dataFile.fileName();
|
||||
dataFile.setAutoRemove(false);
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
#include <coreplugin/find/basetextfind.h>
|
||||
#include <texteditor/fontsettings.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
@@ -659,12 +660,7 @@ static inline QString msgCheckScript(const QString &workingDir, const QString &c
|
||||
bool VcsBaseSubmitEditor::runSubmitMessageCheckScript(const QString &checkScript, QString *errorMessage) const
|
||||
{
|
||||
// Write out message
|
||||
QString tempFilePattern = QDir::tempPath();
|
||||
const QChar slash = QLatin1Char('/');
|
||||
if (!tempFilePattern.endsWith(slash))
|
||||
tempFilePattern += slash;
|
||||
tempFilePattern += QLatin1String("msgXXXXXX.txt");
|
||||
TempFileSaver saver(tempFilePattern);
|
||||
TempFileSaver saver(Utils::TemporaryDirectory::masterDirectoryPath() + "/msgXXXXXX.txt");
|
||||
saver.write(fileContents());
|
||||
if (!saver.finalize(errorMessage))
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user