Utils: Make path cleaning platform agnostic

Unfortunately, QDir::cleanPath() only cleans according to the rules
of the host system, which can be wrong in remote setups.

As the implementation is not accessible/tweakable from the outside,
copy the relevant code and remove the platform #ifdef's.

Change-Id: Ife9a925412a12d3cef21ed3721a387c61c152ddf
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2022-07-14 15:04:44 +02:00
parent 712311b20c
commit dd585c601c
5 changed files with 256 additions and 31 deletions

View File

@@ -205,7 +205,10 @@ public:
[[nodiscard]] bool ensureReachable(const FilePath &other) const;
QString toFSPathString() const;
[[nodiscard]] QString toFSPathString() const;
[[nodiscard]] static int rootLength(const QStringView path); // Assumes no scheme and host
[[nodiscard]] static int schemeAndHostLength(const QStringView path);
private:
friend class ::tst_fileutils;
@@ -213,9 +216,6 @@ private:
void setPath(QStringView path);
void setFromString(const QString &filepath);
static int rootLength(const QStringView path);
static int schemeAndHostLength(const QStringView path);
[[nodiscard]] QString mapToDevicePath() const;
[[nodiscard]] QString encodedHost() const;