forked from qt-creator/qt-creator
Utils: Guard QFileInfo usages of non local FilePaths
Helps keeping track of usages of potential wrong paths and partially makes sure to not leave the correct device. Change-Id: I19fff7ae8abc3fa6045f7d4459f1140ba71e4f16 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -438,6 +438,7 @@ FilePath FilePath::fromFileInfo(const QFileInfo &info)
|
|||||||
/// \returns a QFileInfo
|
/// \returns a QFileInfo
|
||||||
QFileInfo FilePath::toFileInfo() const
|
QFileInfo FilePath::toFileInfo() const
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(!needsDevice(), return QFileInfo());
|
||||||
return QFileInfo(m_data);
|
return QFileInfo(m_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -831,6 +832,7 @@ FilePath FilePath::parentDir() const
|
|||||||
|
|
||||||
FilePath FilePath::absolutePath() const
|
FilePath FilePath::absolutePath() const
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(!needsDevice(), return *this);
|
||||||
FilePath result = *this;
|
FilePath result = *this;
|
||||||
result.m_data = QFileInfo(m_data).absolutePath();
|
result.m_data = QFileInfo(m_data).absolutePath();
|
||||||
return result;
|
return result;
|
||||||
@@ -838,6 +840,7 @@ FilePath FilePath::absolutePath() const
|
|||||||
|
|
||||||
FilePath FilePath::absoluteFilePath() const
|
FilePath FilePath::absoluteFilePath() const
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(!needsDevice(), return *this);
|
||||||
FilePath result = *this;
|
FilePath result = *this;
|
||||||
result.m_data = QFileInfo(m_data).absoluteFilePath();
|
result.m_data = QFileInfo(m_data).absoluteFilePath();
|
||||||
return result;
|
return result;
|
||||||
@@ -1056,6 +1059,7 @@ FilePath FilePath::relativeChildPath(const FilePath &parent) const
|
|||||||
///
|
///
|
||||||
FilePath FilePath::relativePath(const FilePath &anchor) const
|
FilePath FilePath::relativePath(const FilePath &anchor) const
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(!needsDevice(), return *this);
|
||||||
const QFileInfo fileInfo(m_data);
|
const QFileInfo fileInfo(m_data);
|
||||||
QString absolutePath;
|
QString absolutePath;
|
||||||
QString filename;
|
QString filename;
|
||||||
|
Reference in New Issue
Block a user