Core: Make UtilsJsExtension::relativeFilePath() work on remote

Task-number: QTCREATORBUG-28355
Change-Id: I67fad186ed31e42688835b38177f3fb7cd59c1d0
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
hjk
2022-11-29 17:38:45 +01:00
parent ad072db2b6
commit 5f4a5802cc
3 changed files with 11 additions and 11 deletions

View File

@@ -234,9 +234,10 @@ public:
[[nodiscard]] static int rootLength(const QStringView path); // Assumes no scheme and host
[[nodiscard]] static int schemeAndHostLength(const QStringView path);
static QString calcRelativePath(const QString &absolutePath, const QString &absoluteAnchorPath);
private:
friend class ::tst_fileutils;
static QString calcRelativePath(const QString &absolutePath, const QString &absoluteAnchorPath);
void setPath(QStringView path);
void setFromString(const QString &filepath);
DeviceFileAccess *fileAccess() const;

View File

@@ -16,8 +16,9 @@
#include <QVariant>
#include <QVersionNumber>
namespace Core {
namespace Internal {
using namespace Utils;
namespace Core::Internal {
QString UtilsJsExtension::qtVersion() const
{
@@ -83,7 +84,9 @@ QString UtilsJsExtension::absoluteFilePath(const QString &in) const
QString UtilsJsExtension::relativeFilePath(const QString &path, const QString &base) const
{
return QDir(base).relativeFilePath(path);
const FilePath basePath = FilePath::fromString(base).cleanPath();
const FilePath filePath = FilePath::fromString(path).cleanPath();
return FilePath::calcRelativePath(filePath.toFSPathString(), basePath.toFSPathString());
}
bool UtilsJsExtension::exists(const QString &in) const
@@ -175,5 +178,4 @@ QString UtilsJsExtension::qtQuickVersion(const QString &filePath) const
return QLatin1String("2.15");
}
} // namespace Internal
} // namespace Core
} // Core::Internal

View File

@@ -8,9 +8,7 @@
#include <QObject>
#include <QSet>
namespace Core {
namespace Internal {
namespace Core::Internal {
class UtilsJsExtension : public QObject
{
@@ -59,5 +57,4 @@ public:
Q_INVOKABLE QString qtQuickVersion(const QString &filePath) const;
};
} // namespace Internal
} // namespace Core
} // Core::Internal