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
@@ -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())
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user