Commit Graph

122 Commits

Author SHA1 Message Date
Marcus Tillmanns
24d11e66b4 Utils: Fix FilePath::isChildOf
Previously isChildOf would only look at the path.
But if the two paths are from different devices
it would mistakenly return true if the paths were
similar.

Change-Id: Icdb1aebe61167183ec85fa56ae0708681a59a9f8
Reviewed-by: hjk <hjk@qt.io>
2022-10-14 09:49:10 +00:00
hjk
296538d23d Utils: Add FilePath::isSymLink
Needed to fix GenericUploadStep handle the device->device case.

Change-Id: I551ac0957879e5b8737c22fa823d8b2e6bec0b5e
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-10-14 08:29:08 +00:00
Marcus Tillmanns
a22d62e57d Utils: Add FilePath::isSameFile()
FilePath::isSameFile() checks if two files are the same file.
It first checks if its on the same device. If it is, it will
try to read the fileId of the files and compare them.

Change-Id: I83668955cacd4e5ed03d43a3fee2be29e9d0a6f0
Reviewed-by: hjk <hjk@qt.io>
2022-10-13 11:25:48 +00:00
hjk
1fa3255242 Utils: Split off file access interface from IDevice
The file accessing functions form now a class hierarchy by themselves,
the devices return a suitable point.

The previous implementation was mildly confusing by the special handling
of the DesktopDevice, fallbacks and remote cases in the same function
leading to unnecessary boilerplate when adding new functions and
codepaths that sometimes passed the FilePath API twice.

Implemented are a "DesktopDeviceFileAccess" taking care of the
previous !needsDevice() branches and a "UnixDeviceFileAccess"
covering the current docker and RL uses.

As a side-effect this unifies to a large degree the current docker
and RL code paths with were occasionally deviating from each other
while they shouldn't.

Change-Id: I4ff59d4be2a07d13e2ca5e9ace26a84160a87c9d
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-10-13 10:38:35 +00:00
Marcus Tillmanns
6c858c5cd6 Utils: Fix find name operator precedence
Change-Id: I553656c3aaa96230a6be60fdff69e90be03684be
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-10-13 07:36:03 +00:00
Marcus Tillmanns
07f040bd1f Utils: Allow [] wildcard when using find
Change-Id: Idc8074b85213c6d301279a01cd1b838584a66133
Reviewed-by: hjk <hjk@qt.io>
2022-10-13 07:13:35 +00:00
hjk
b1471fe61f Utils: Combine some of the iterateWithFind overloads
Change-Id: I668447d0049f2e35cd0c76d2c5708779196167ec
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2022-10-12 08:59:32 +00:00
Christian Stenger
9ae0399722 Utils: Fix build before Qt6.2
FilePath is used from sdktool as well.
Amends ae58d373b0.

Change-Id: Ia4846b7f8a91fa503c5039c44e65ba21e84e9319
Reviewed-by: hjk <hjk@qt.io>
2022-10-12 06:26:15 +00:00
Jarek Kobus
c50891611a FilePath: Fix absoluteFilePath to behave like absolutePath
Change-Id: Ibb2cba32c40ec9febab5f20c78156481525c8904
Reviewed-by: hjk <hjk@qt.io>
2022-10-11 14:33:35 +00:00
Marcus Tillmanns
ae58d373b0 Add FSEngine FilePath Cache
To speed up file dialogs we introduce a 1 minute cache for
the FilePathInfo.

A new version of "IDevice::iterateDirectories" allows implementations to
provide the FilePathInfo directly.

DockerDevice implements fetching the filePathInfo during
iterateDirectories which greatly improves the speed again.

Change-Id: I24ac16adb2478cbf16a22012e72fcb8910dcdac5
Reviewed-by: hjk <hjk@qt.io>
2022-10-11 08:53:02 +00:00
hjk
2e38cb6848 Utils: Add an offset parameter to the content writing FilePath function
Use QFile::seek to implement locally and a dd seek based poor man's
implementation on RL and docker.

Change-Id: I241d1c34c00e991845d132ad8edefa1377ba1311
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-10-10 16:08:28 +00:00
Eike Ziller
ce9da99528 FilePath: Fix isRelativePath for QRC paths
Implicitly fixing methods like absoluteFilePath too.

Fixes e.g. JSON wizards that are registered from a plugin QRC file, like
McuSupport wizards (run with McuSupport plugin enabled and create a
"Application (Qt for MCU)" application).

Change-Id: I296ba1c5eb63c9eb27f9a55e65019125faf546ea
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-10-10 06:14:44 +00:00
hjk
7a1696a0ac Utils: Add a convienience function FileFilter::asFindArguments
Re-usable in a variety of unix-based devices.

Change-Id: I480ad9b128336059752b99dc1f1ae3b4899a4077
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-10-06 16:00:15 +00:00
hjk
23e96dd6fe Utils: Use a single QString as data store for FilePath
Plus a few integers to get access to the pieces.

This reduces sizeof(FilePath) from 72 to 32.

Change-Id: I65eb856ad47b6a250c705d8d01893781a21d8e02
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-10-04 07:27:16 +00:00
Marcus Tillmanns
d510451b11 FilePath: Don't searchInPath if already absolute
searchInPath returns *this if it is already absolute.

Change-Id: Ie1fe8beed67402a9c7eacf04b34bbfb3296b2180
Reviewed-by: hjk <hjk@qt.io>
2022-09-29 07:50:29 +00:00
Eike Ziller
4fd4b42f3d Fix FilePath::absoluteFilePath for default constructed file path
FilePath::absoluteFilePath() would consider an empty path to be
relative, and resolved it wrt the current working directory. That is
unexpected in the sense that QFileInfo::absoluteFilePath behaves
differently, and lead to a crash down the line when e.g. a diff editor
was opened when the current working directory is '/' (the default on
macOS when started with "open" or from Finder, Dock or Spotlight).

Make FilePath::absoluteFilePath() return and empty path if the input was
empty.

Change-Id: Ie0d4da50afa24134bd56505b2f4abcf382eee982
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-09-26 07:43:36 +00:00
Christian Stenger
805e536df6 Utils: Fix result of fileNameWithPathComponents()
Combination of bf8bf1adc0 and d83f9d71cc broke
the resulting string.
Fixes tst_fileutils file name tests.

Change-Id: I69c485e52bbf76093b903b407ab2ff2f58d28a0d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-09-23 12:39:32 +00:00
hjk
d5412588fd Utils: Remove QDir use from parentDir() implementation
cleanPath() is good enough now.

Change-Id: I3f0e7a96496c11bc90c4eb83c35d706aeab93aa6
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-23 12:21:12 +00:00
hjk
dd585c601c 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>
2022-09-23 09:25:05 +00:00
David Schulz
d83f9d71cc Utils: use native path in FilePath::displayName
Change-Id: Idf82f963cbdee648c53038af478963044b3aa631
Reviewed-by: hjk <hjk@qt.io>
2022-09-23 06:18:57 +00:00
hjk
a35a19d165 Utils: Introduce FilePath::{root,schemeAndHost}Length(QStringView)
Intended as helpers for parentDir() to stop when cutting components.

Change-Id: I7615803743351a733d6f3cc9813e9de85973dc61
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2022-09-22 09:19:42 +00:00
Marcus Tillmanns
df859d891d Filepath: Add ::isSameDevice
Change-Id: I3990429b59759d5f72ed95e3a0d1723d3bb7bb82
Reviewed-by: hjk <hjk@qt.io>
2022-09-20 10:11:33 +00:00
hjk
3dff69979b Utils: "Fix" UNC file path parsing
... by adapting the expectations.

Change-Id: If3a3fe2def370440f1edbbcb5a1c2646f1239f67
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-19 13:24:43 +00:00
hjk
3522097a8b Utils: Normalize backslashes on FilePath parsing again
Change-Id: I8ee0bc53244785d78acfad406664a907ab088301
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-19 13:24:20 +00:00
hjk
bd8d525d70 Utils: Drop QDir::rootPath() uses from FilePath parsing
Fixes three of the EXPECTED_FAIL.

Change-Id: Idf5356cf6ff151c61166404e2b2697b6b0acabd9
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-19 13:23:47 +00:00
hjk
b3200b7730 Utils: Move 'isWindowsHost' test to startsWithDriveLetter callers
"Fixes" one Q_SKIP and makes the implementation OS-agnostic.

FilePath::osType() actually depends on the host system for not fully
qualified file paths, and that doesn't seem to be the right thing to do
in all cases. The caller may actually have more context to decide
whether this is needed (e.g. in pathchooser.cpp in the context of
"return value from a GUI element, i.e. 'host' implied).

Change-Id: Iff80c17094d2deec79d34d0527223fbcf8294935
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-19 13:14:58 +00:00
Marcus Tillmanns
88969b79eb Filepath: Add ensureReachable function
ensureReachable checks whether the device (if any) of the filepath
can "reach" another FilePath. Devices can then either return false
if they don't, or take action to ensure that the path can be reached.

Change-Id: Ic1a315b9e7d9e37ee649989313a4cdb195a7e4d9
Reviewed-by: hjk <hjk@qt.io>
2022-09-19 11:13:08 +00:00
hjk
06334e1816 Utils: Replace FilePath::rootPath() by some isRootPath()
Keeps more context to make it host-independent later.

Change-Id: I0f8ad3e8794daa6324662847203200ae378d34b4
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-19 10:39:55 +00:00
hjk
85c899de63 Utils: Make root recognition in FilePath::fromString host agnostic
Fixes a few XFAILS and a QSKIP

Change-Id: I012d873097dfa0ea565adc4e9a2b34f6c21db9dc
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-19 08:51:20 +00:00
hjk
2f2e266fdf Utils: Make FilePath::toString() output OS-independent again
Change-Id: Ica7c09ea39a38e3425b28c63b6001ad7ad641a4f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-09-19 07:44:26 +00:00
hjk
31556332f5 Utils: Make FilePath::toFSPathString a full copy of toString
Changing the toString() to prepend system-specific prefixes
to cater for the remote filesystem model handling had unintended
sideeffects.

This here is the first step to split both paths.

Change-Id: I66cdd9a87802408e2ba95c2e29b9d7cce7fe2553
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-16 08:24:20 +00:00
Eike Ziller
e7ddd8a5b7 FilePath: Return optional bytearray from device hooks
For differentiating between "error" and "empty file".

Change-Id: I1806bb7386f5e7db28489f9f7e685648bfc20110
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-09-15 11:28:18 +00:00
Marcus Tillmanns
2f0a26c1f5 Filepath: Revert "root"
Change-Id: I3f8e8d8eb32f4e3246942aad2f1205034bfafc07
Reviewed-by: hjk <hjk@qt.io>
2022-09-13 07:58:04 +00:00
Eike Ziller
2c51e4bc17 FilePath: Return optional bytearray for file contents
For differentiating between "error" and "empty file".

Change-Id: I2c019ceac625e7be3180afa4d47ae3a24df91c1d
Reviewed-by: hjk <hjk@qt.io>
2022-09-12 11:57:04 +00:00
Christian Kandeler
8e9e457daa Utils: Make FilePath::canonicalPath() work for directories
... in the Windows implementation.
Amends 1073f89886.

Change-Id: Id264e9844634fc8d2afae5b2a7a2355882136315
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-09-07 07:35:42 +00:00
hjk
ba2956984c Utils: Add a private FilePath::encodedHost() helper
Change-Id: I7ce1c7e1e892b3a14f9d31e106b58e8340d574d8
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-06 11:09:40 +00:00
Eike Ziller
b1fd3f6e33 Fix build of sdktool
QStringView::first was introduced in Qt 6.0, use QStringView::left
instead

Amends a8145ff6c9

Change-Id: I6983eb0f35cc6f4887160f1d201a43db0fee361b
Reviewed-by: hjk <hjk@qt.io>
2022-09-06 09:33:54 +00:00
Christian Kandeler
1073f89886 Utils: Try harder in FilePath::canonicalPath()
On Windows, we now also resolve SUBST drives and NTFS alias mounts.

Task-number: QTCREATORBUG-27869
Task-number: QTCREATORBUG-28031
Change-Id: Ia6b16787e8a691118d56579c0825bb20b066f9b8
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-09-06 08:15:11 +00:00
hjk
a8145ff6c9 Utils: Replace FilePath::m_root member by a int m_rootLen
... and keep the string data as part of m_path.

Change-Id: Iaa43183906b59a419ddd78ed0102fe48c686bbb4
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-05 10:15:15 +00:00
hjk
56a8c59845 Utils: Make OsType addition less visible
Change-Id: I092930ef6b0ed6876e32ed6b0c78d6bd58becddc
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-02 08:25:27 +00:00
hjk
7cfc3d26bc Utils: Replace FilePath part setters
... by a combined version. This will make it easier to store the parts
in one QString object.

Change-Id: Ie85a77e3957c78a30e49998fe2e617af35a8ad17
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-01 07:59:29 +00:00
Eike Ziller
04e50438eb Utils: Remove Utils::optional
Since we are now requiring macOS 10.14 we can remove our local
implementation of optional and use std::optional for macOS too.

Change-Id: I2bd018261b68da64f7f031a812045dd7784697e1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2022-09-01 06:58:04 +00:00
Marcus Tillmanns
1af0eb3504 FilePath: Fix setFromString for short urls
FilePath::setFromString failed previously for URLs
without a path, e.g. "http://qt.io" as it would add
the scheme and host to its path.

Also added a test for various URLs

Change-Id: I6c22489c0af7154734390aa1e5e12693864210b1
Reviewed-by: hjk <hjk@qt.io>
2022-09-01 06:19:01 +00:00
Lucie Gérard
a7956df3ca Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.

Task-number: QTBUG-67283
Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-08-26 12:27:18 +00:00
hjk
11648298c8 Utils: Port some FilePath part accessors to QStringView
Change-Id: Ib5cc262e44c73880b6538eed714365e3d685870a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-08-22 13:27:56 +00:00
Eike Ziller
60f2945f08 FilePath: Remove unused include
Change-Id: I0ad971a65d25bcecf19c2094225f7f95f9121385
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-08-22 08:16:37 +00:00
Marcus Tillmanns
4f0ac5678f FilePath: Fix operator+ to use stringAppend instead of pathAppended
Change-Id: I643a2e9eed22fafc793bbc75cba0344c4005b3f3
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-08-16 11:35:12 +00:00
Marcus Tillmanns
50bedd5544 FilePath: Fix UNC root/path parsing
* Fixed UNC path parsing to correctly split between root and path
* Fixed tst_fileutils to correspond to windows path handling.

Change-Id: I2849738696a39e8282068ab164514f806f2c5fcf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-08-11 13:54:14 +00:00
Marcus Tillmanns
cd919e6f61 FilePath: Fix for operator+(QString)
Change-Id: I3b9889c8b2cdc8a9d1bf94c3e7a8627e2ff2ac35
Reviewed-by: hjk <hjk@qt.io>
2022-08-11 09:31:26 +00:00
Marcus Tillmanns
aeb33310cb FilePath: Fix parsing of qrc paths
Change-Id: I50d404bafb8d1cb4f0663cd424e1034ae26bb903
Reviewed-by: hjk <hjk@qt.io>
2022-08-11 07:57:51 +00:00