Commit Graph

191 Commits

Author SHA1 Message Date
Eike Ziller
380f7622de Merge remote-tracking branch 'origin/10.0'
Conflicts:
	src/plugins/debugger/watchhandler.cpp

Change-Id: If759b6260dfa008738d3a0ce543eb0eead8a8bba
2023-02-27 09:48:12 +01:00
Leena Miettinen
708c629133 Utils: Use double quotes for emphasis in UI text
Change-Id: I00b27ee40ba131ec6472b03ac7f23c93639a9cea
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-02-24 16:51:27 +00:00
Marcus Tillmanns
a62c5cf89a Utils: Cleanup searchInX functions
Also move some often used types into new file "utiltypes.h"

Change-Id: I3f152d1dc2f96ba0259ad6c098d9ac5ee03a59f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2023-02-24 15:13:32 +00:00
Marcus Tillmanns
d5a9e28a96 Utils: Add tst_filepath
Moves all tests that are applicable only to FilePath over from
tst_fileutils.

Change-Id: Ic331e1470a7479ee2f8ba38baec84124982a000a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-02-24 09:45:56 +00:00
Marcus Tillmanns
00fd4c8fea Utils: Fix diriterator for scheme folders
Previously the "fileName" of every device inside a scheme subfolder
would be empty. Therefore QDirIterator would skip them.

Change-Id: Ifa46859aadbd8a81364a1fe0a72b9a50a7a396ca
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-02-23 10:25:15 +00:00
Eike Ziller
37ec527e6d Fix tilde expansion in FilePath::fromUserInput
It was not working for just "~/" without additional path component.

Change-Id: I559a7771fc09d2e604f567548585a668e8809729
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-02-23 07:12:15 +00:00
Marcus Tillmanns
8ed10639b6 Utils: Make getFileAccess static
Change-Id: I6af1ee8be88bf378bd1ddff8fee02005cc9ed6cb
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-02-17 11:22:50 +00:00
Marcus Tillmanns
1523f49e5c Utils: Add PathFilter to FilePath::searchInPath
Change-Id: Iccbecc7401f17208487113f89e49ed7103acf9d6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2023-02-09 11:56:28 +00:00
Marcus Tillmanns
516fce6f53 Utils: Add FilePath::tmpDir and createTempFile
Change-Id: I6f3143e59a87edffeee5e08708ba721293a8a369
Reviewed-by: hjk <hjk@qt.io>
2023-02-07 09:28:38 +00:00
Marcus Tillmanns
0c1b59fb1a Utils: Use isSameDevice in copyFile
Change-Id: I36389a88c4474d46ef4fdb9369cf9f4219f6099d
Reviewed-by: hjk <hjk@qt.io>
2023-02-07 08:17:16 +00:00
Alessandro Portale
4d6827dde9 Utils: Tr::tr
Change-Id: Ic03e20993f05fb5b49a12c891d86afb2c8e18e08
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2023-02-01 13:48:22 +00:00
hjk
1285b80c40 Utils: Use an enum indication the possible abort of an dir iteration
The bool is not really clear.

Change-Id: I4ce6412736aec6b1853fd53d4e535ad045748350
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-01-26 07:38:21 +00:00
Marcus Tillmanns
7cb74e325f Utils: Add FilePath::copyRecursively
Change-Id: I0cb07158906a5e163ea35670f46f3b4fd9ec40b8
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-01-25 07:29:52 +00:00
hjk
34fd5b3ced Utils: Improve FilePath::toUrl for local cases
Change-Id: If1674f97eeeb91173dc2b482662228c1c3f0f332
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-24 08:33:43 +00:00
Christian Stenger
d9de9db6f8 Utils: Adapt to change in FilePath
Change-Id: Ibd3c53c49390cbf77d8b0563bab7ddff216394c7
Reviewed-by: hjk <hjk@qt.io>
2023-01-19 05:34:48 +00:00
Christian Stenger
7b74432fb1 Utils: Adapt to change in FilePath
Change-Id: Ie828342789e28d4b99138ac02d9e2644c5e24431
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2023-01-17 14:27:55 +00:00
hjk
7cd2026fa2 Utils: Re-add some safety net in FilePath::setPath()
Amends c08317b5a6

Change-Id: I3b9bc61346aa60280beb3b29c33c0f76017e407a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-16 14:16:12 +00:00
Marcus Tillmanns
21ef25a0f5 Utils: Add FilePath.hasFileAccess()
FilePath::hasFileAccess allows a user to test if a specific device
can access files. This is faster than calling "exists()" as it does
not have to actually check anything on the device.

Task-number: QTCREATORBUG-28531
Change-Id: I94b5b9e0ae020b81f126c61fd06bb25f3d4a88cb
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-01-12 14:06:09 +00:00
Marcus Tillmanns
b39010af79 Utils: Allow FilePath::onDevice for local paths
Change-Id: I1ae62e077382abddbb32327897e87331cfc02476
Reviewed-by: hjk <hjk@qt.io>
2023-01-11 07:59:06 +00:00
hjk
2c65bfa0ea Utils: Fix FilePath::withTildeHomePath()
Or rather, re-instate previous behavior.

Amends c9023e85108.

Change-Id: I1be0dd8c42db8430323b8368a8164b1623d5ced5
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-01-10 15:27:59 +00:00
Christian Stenger
677fd6ba9a Utils: Fix compile with MinGW
Amends fbb8d94e55.

Change-Id: Ib62733031bfed435592da57d7f52e10473953669
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-10 10:12:44 +00:00
hjk
66c08a824d Utils: Rename most FilePath::{from,to}Variant uses to {from,to}Settings
Specifies the main purpose more clearly. The remaining ones a "true"
(internal) variants in models and as action data.

Change-Id: I8dd3c846e419f29d88283c2f48268ef6685b19fe
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-10 09:00:30 +00:00
Marcus Tillmanns
aee7afd50b ProjectExplorer: Improve error reporting
Previously anytime a FilePath operation tried to access a device that
does not have a DeviceFileAccess an error message would be thrown.

This patch makes it possible to differentiate between the device not
being found, and the device just not having a DeviceFileAccess
interface.

Also the error message in DeviceFileAccess::exists() was removed as
its not an error to ask if something exists even if it does not.

Change-Id: Ib8c2e08132159d0d97bcd049b59436eb17bdbacd
Reviewed-by: hjk <hjk@qt.io>
2023-01-10 07:12:39 +00:00
hjk
fbb8d94e55 Utils: Use hidden friends for FilePath comparison, hash and debug
Change-Id: Ic458d64cecdc811bac6b1cfaeae344f1da1b8211
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-06 12:54:59 +00:00
Kai Köhne
56baf8c058 Remove GPL-3.0+ from license identifiers
Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0,
this applies only to a hypothetical newer version of GPL, that doesn't
exist yet. If such a version emerges, we can still decide to relicense...

While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only

Change was done by running

  find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \;

Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-06 11:15:13 +00:00
hjk
ac9023e851 Utils: Make Utils::withTildeHomePath a FilePath member
Gets .osType() right in remote cases.

Change-Id: I6397996062d976d7db690c5729dd4faa1f459563
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-01-05 10:17:10 +00:00
hjk
b00442e946 Utils: Make FilePath doc sources a bit more unitorm
Change-Id: I1250cc4bdb354827836b2193bcb64af6fd7f596f
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-03 14:28:07 +00:00
Artem Sokolovskii
15fa9e7096 FileFinder: FilePathify
Change-Id: I7a4bcb05f85058ddcaf0c69c01b0587116410d95
Reviewed-by: hjk <hjk@qt.io>
2023-01-03 13:39:49 +00:00
hjk
09df8dfe44 Utils: Add a bit more and fix some FilePath explanation
Change-Id: I3655fee683ec2e9a48cc9141597398c6ea4d6110
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-01-03 13:09:31 +00:00
hjk
4ea5a7abec Utils: Avoid one case of passing an empty path to isRelativePath()
The distiction relative/absolute path is not broad enough to
cover all situations like e.g. Windows paths with drive letter
but not starting with backslash, and generally also rarely needed
in user code. The situation doesn't get better with "convenience
defaults", like empty path meaning depending on context.

Mid-term I'd like to ramp down uses in user code, moving corner-case
handling to filepath.cpp behind "higher level" FilePath API.

This here is one step towards this goal.

Change-Id: I070112810a1628ced035e90cc7dc679e2248d688
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-02 10:47:38 +00:00
Marcus Tillmanns
0aeec80eeb Docker: Add Filepath::localSource()
FilePath::localSource can return a filepath that represents a local version
of a remote file.

It is used to let the debugger select the local version of a file when
debugging a remote target.

Change-Id: Ieb934ef0d454e8ff55e71df41dca825974d85da7
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-12-16 12:27:49 +00:00
hjk
a1711fc5ba Utils: Add convenience functions FilePath::path{List,Component}Separator
Change-Id: Ib00aace2d5e98fa69a5a23b3950e560aefc662f6
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-12-15 12:58:09 +00:00
Marcus Tillmanns
eca7044361 Utils: Add std::expected implementation
Adds a std::expected implementation that is compatible with >= C++11.

FilePath::fileContents and FilePath::writeFileContents as well as
FilePath::copyFile are changed to return std::expected.

A couple of macros have been added to aid in using the expected types.

An auto test was added showing how to use the library.

Change-Id: Ibe3aecfc1029a0cf13b45bf5184ff03a04a2393b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-12-14 10:39:29 +00:00
hjk
9bac0d7f4c Utils: Be a bit more informative in failing FilePath accesses
Change-Id: I2e30998d2d5cd3159b28996d1102c65cbb9ad03b
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-12-14 08:34:51 +00:00
hjk
8e8afd3cf6 Utils: Remove FilePath::fromUrl()
Even though the concepts are similar, direct conversion is
usually neither desired (lossy) nor needed.

Change-Id: Id5c9e69d0597ed867cbda25f3fc4619a9fe90966
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-12-14 08:27:23 +00:00
hjk
4d80daf71a Utils: Use QStringView in FilePath::setFromString
Change-Id: I830f4b3a7a12bfb4ddcbef443b53a37bb24bc992
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-12-13 06:35:48 +00:00
Marcus Tillmanns
d3487b1bde Utils: Fix FilePath::searchInPath remotely
Change-Id: I49bd7fd96427b55d28743eab277c72710a2ac6c0
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-12-09 14:00:09 +00:00
Jarek Kobus
834f89acf2 Remove unused variables
Change-Id: I653f6fa71bb04e049d4e1848a7e38a606692e678
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-12-09 13:01:53 +00:00
hjk
c08317b5a6 Utils: Remove slash normalization in critical path
Should be done by callers, most notably fromUserInput

Change-Id: I0dec8e3ab76d49d0ddf4da3088499e71c536ab83
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
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-12-09 09:24:43 +00:00
hjk
5c7d842975 Utils: Compile fix after SiC change in Qt Core
__/__/libs/utils/filepath.cpp.o -c /data/dev/creator-bisect/src/libs/utils/filepath.cpp
/data/dev/creator-bisect/src/libs/utils/filepath.cpp: In static member function ‘static QString Utils::FilePath::calcRelativePath(const QString&, const QString&)’:
/data/dev/creator-bisect/src/libs/utils/filepath.cpp:1121:26: error: ambiguous overload for ‘operator+=’ (operand types are ‘QString’ and ‘const char [3]’)
 1121 |             relativePath += "..";
      |             ~~~~~~~~~~~~~^~~~~~~
In file included from /data/dev/qt-6/qtbase/include/QtCore/qstring.h:1,
                 from /data/dev/qt-6/qtbase/src/corelib/time/qdatetime.h:8,
                 from /data/dev/qt-6/qtbase/include/QtCore/qdatetime.h:1,
                 from /data/dev/qt-6/qtbase/include/QtCore/QDateTime:1,
                 from /data/dev/creator-bisect/src/libs/utils/filepathinfo.h:6,
                 from /data/dev/creator-bisect/src/libs/utils/filepath.h:8,
                 from /data/dev/creator-bisect/src/libs/utils/filepath.cpp:4:
/data/dev/qt-6/qtbase/src/corelib/text/qstring.h:708:21: note: candidate: ‘QString& QString::operator+=(const QString&)’
  708 |     inline QString &operator+=(const QString &s) { return append(s); }
      |                     ^~~~~~~~
/data/dev/qt-6/qtbase/src/corelib/text/qstring.h:711:14: note: candidate: ‘QString& QString::operator+=(q_no_char8_t::QUtf8StringView)’
  711 |     QString &operator+=(QUtf8StringView s) { return append(s); }
      |              ^~~~~~~~

Change-Id: I7da443cc6070f406252106a26179afb36fa24eee
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-12-06 09:43:49 +00:00
hjk
e4c49b720e Utils: Consolidate the isRelative/isAbsolute implementations
Even if we do it wrong in corner cases, we should do it consistently.

Change-Id: I68d5a6e55ede889cb44bedb46d0ea545dae7ba2c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-12-01 12:51:22 +00:00
hjk
7e9d50a2c9 Remove a few now-unnecessary cleanPath in conjunction with resolvePath
Change-Id: I05ee0116183a30e907fbd8e0b4faae9e6e58723d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-11-30 13:32:05 +00:00
hjk
4eee8a12fb Utils: Clean path in FilePath::resolvePath
Change-Id: I27e34e21c2922db4d7598c77688133aebf6ce893
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-11-30 11:47:33 +00:00
hjk
4417c48e7b Utils: Remove FilePath::operator+()
This was a alias for .stringAppended(), but can be used too easily
when .pathAppended() is meant.

Change-Id: Ia3b64d39828d4074b43d87c923ce3a6a87038948
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-11-30 06:57:02 +00:00
hjk
8249eabbad Utils: FsEngine micro-optimizations
Mostly for shorter code, but also save a few cycles due to less
string construction and run time dispatch.

Also, make testFilePathFromToString() test two paths instead one path
twice.

Change-Id: I50a3145bca1a4b262a15e96173ea7ebd9cb678ad
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-11-29 10:17:41 +00:00
Orgad Shaneh
157f2bcd39 Merge remote-tracking branch 'origin/9.0'
Change-Id: I231d35f492713f317773b79478b5f7fb97a4fe50
2022-11-28 17:29:19 +02:00
hjk
a146403596 Utils: Make FilePath::refersToExe(...) return the found item
... and use in on the CMake side.

Change-Id: Ib215ebc4f87beb67b6a302d0c42e7b955a2fa5b7
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2022-11-28 11:30:38 +00:00
Orgad Shaneh
4225f475a4 FilePath: Do not strip macros when normalizing path
Fixes: QTCREATORBUG-28484
Change-Id: Id6bcd2aef048bd355c196013c54799e4944135bd
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-11-25 11:57:04 +00:00
hjk
a94f37c8b0 Utils: Add FilePath::{suffix,fileName}View functions
Can save a few cycles in some cases.

Change-Id: I0da3ad9ae2127e20f8e90d68f924e87661028071
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2022-11-24 16:52:57 +00:00
Thomas Hartmann
5995810d34 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>
(cherry picked from commit e471417539)
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2022-11-24 10:10:42 +00:00