Commit Graph

188 Commits

Author SHA1 Message Date
hjk
02c041c13a Utils: Introduce FilePath::isSameExecutable()
... to replace Environment::isSameExectuable().

New code is a filepathified copy of the orginal.

Change-Id: Iebf61cd183c9a5c03a5b8a90a33b5e074af9ecbe
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-11-21 11:42:12 +00:00
Eike Ziller
5c37cfc54b FilePath: Avoid QStringView::first, which is only available in Qt 6
but FilePath is still used with sdktool = qt 5.15.2

Change-Id: Ibb196411fc37efc74db6df4ab024ac98db6cf4ea
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-11-18 14:51:09 +00:00
Eike Ziller
c84d12227d FilePath: Fix pathView() and use at more places
pathView was constructing a QStringView on a temporary, which silently
does weird stuff.

After the change to a single-string representation, the QString
construction for path() is expansive for the comparison operators.

Change-Id: I543c7115d3ad52f971d1692230b6eab82645b810
Reviewed-by: hjk <hjk@qt.io>
2022-11-18 09:35:18 +00:00
Thomas Hartmann
e471417539 FilePath: optimize comparison
* The QTC_ASSERT in pathView() is quite expensive
* Constructing the scheme using scheme() is not required

Change-Id: Ibea33dd6abf67c8bd184d118f23e2598075c362c
Reviewed-by: hjk <hjk@qt.io>
2022-11-18 08:41:30 +00:00
hjk
6046fa8354 Utils: Fix FilePath::hash() regarding to case sensitivity
Change-Id: I2b7f7fa141ec80ec6f0256c4f384ed622b35ba15
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-11-18 08:39:03 +00:00
Eike Ziller
81629e9228 Merge remote-tracking branch 'origin/9.0'
Change-Id: Id7665d5a269ef58cbbb2dbfc1e5b0d1820c4e13e
2022-11-17 16:11:52 +01:00
hjk
e202138fb0 Utils: Use QStringView in FilePath implementations when it makes sense
Change-Id: I7346d873008f8ff1ab88f298a8d90e41f8c6d0b9
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-11-17 13:12:30 +00:00
Alessandro Portale
9f397de829 Utils: Don't reverse FilePath::dirEntries result by default
QDir::NoSort has the value -1 thus all sort bits set.

Change-Id: I543fa68b11269cd4321b22113fc591f5542c2edd
Reviewed-by: hjk <hjk@qt.io>
2022-11-17 10:23:32 +00:00
hjk
f59ca97a84 Utils: Sanitize FilePath::onDevice()
It's one entry in the FilePath world, so it should start with a QString.

Change-Id: Ib2693f52d56103a4c37ba7361b191c2a5c2a72f8
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-11-17 10:13:05 +00:00
David Schulz
895f88f63a ProjectExplorer: create a root path without scheme for host device
Change-Id: I966db6378dca533c73635803fb177d31b2c625ac
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-11-17 09:39:35 +00:00
hjk
ef658663aa Utils: Remove internal /./ relative path marker
Some creeped into settings earlier, making the paths that were
meant to be empty look non-empty.

Also add a test for FilePath::isEmpty().

Change-Id: I99e3dd673294206558f9fee9b7c7874d2441327e
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-11-16 07:23:46 +00:00
Marcus Tillmanns
d46a079744 Utils: Fix copyFile to include permissions
Also adds line breaks to info output.

Change-Id: I314ab87a47d7bd7541acb6a1553238fcfc27099d
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-10-25 13:31:10 +00:00
Marcus Tillmanns
3ac5051af9 Utils: Fix FilePath::fromString host decoding
Previously FilePath::fromString did not decode %25 (%) and %2f (/),
so a round of ::fromString(::toString()) would not return the same host.

Change-Id: I99c7317fb149443c2e52c099f7da7c4ef6768aff
Reviewed-by: hjk <hjk@qt.io>
2022-10-20 06:45:42 +00:00
hjk
4266f612e6 Utils: Rename FilePath::relativePath() to relativePathFrom()
Hopefully less confusion about the direction.

Change-Id: I61727d6c4d19e0dfe46f24ff24f5d90f9835d05c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-10-18 13:41:24 +00:00
hjk
88837631de Utils: Remove a few QFileInfo uses from FilePath::relativePath
Change-Id: I0896678688cc9f7b1d635890eff0603a89f3b2e3
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-10-17 08:53:35 +00:00
Marcus Tillmanns
0b40e4b032 Utils: Fix FilePath::toFileInfo()
Change-Id: I91f75511758e606c9e9ff1338b272e6b03c26986
Reviewed-by: hjk <hjk@qt.io>
2022-10-14 09:49:48 +00:00
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