Commit Graph

211 Commits

Author SHA1 Message Date
hjk
ae26fa0dd7 Utils: Add a FilePath::searchAllInDirectories
A variation that does not stop on the first found item.
Useful for auto-detection scenarios.

Use "WithAnySuffix" as default to cover .cmd and .bat etc.

Change-Id: I48f36eff06699c046e34c8e2646546bcff20ae8b
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-05-23 12:42:27 +00:00
Leena Miettinen
ce0ab1cd27 Doc: Replace \p with \a and remove \param
The qdoc command for arguments/parameters is \a. It is enough to
place it somewhere in the text to make qdoc happy.

Change-Id: I164fbd63277787a68b0216ad3fbbed768b975d91
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-05-23 09:31:32 +00:00
hjk
c02750428c Utils: Rework FilePath::searchInDirectory
Avoid the detour through Environment::search* by copying and adapting
some code. Long term the Environment::search* functions may go
as FilePath is generally a better entry point into the remote
world nowadays.

Change-Id: I352d6fb68292d76f29a3454a786322bfe081d53d
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-05-23 06:54:44 +00:00
Leena Miettinen
8c288bf05f Doc: Add "\inmodule QtCreator" to \class and \namespace docs
To get rid of QDoc warnings.

Change-Id: Idd39b7ae4327798c376f424c94d6617bcaee2258
Reviewed-by: hjk <hjk@qt.io>
2023-05-22 12:48:35 +00:00
Marcus Tillmanns
69fbe72752 Utils: Use FilePath hash in operator==
Change-Id: Ibbea420a5a5353da221d285b70272cdf9b09d0d0
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-05-12 11:47:08 +00:00
Marcus Tillmanns
6149fd8bfa Utils: Cache FilePath::qHash
Calling toCaseFolded is expensive if the same filepath is hashed
often, so we calculate the hash value once and cache the result.

One such case was found to happen when parsing tests,
as the cpp parser is queried a lot and it uses hash maps / sets
with filepaths.

Change-Id: Ic3ca7f09e8f108f5a89b3fdb17743ae7c3258001
Reviewed-by: hjk <hjk@qt.io>
2023-05-12 11:34:18 +00:00
Marcus Tillmanns
fc95d7a737 Utils: Improve FilePath::sort
Remove the conversion to/from QString for sorting.

Change-Id: I89921328b6d9e952c802d41998495bd2ffbb9f99
Reviewed-by: hjk <hjk@qt.io>
2023-05-10 08:56:32 +00:00
Jarek Kobus
c75b59f9b4 Process: Rename QtcProcessPrivate -> ProcessPrivate
Rename the logging category for Process.
Fix inline comments accordingly.
Adapt warning/debug messages accordingly.

Change-Id: I2b1f0f558701def3afa3c1b04adf629833dba9e7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2023-05-10 06:07:22 +00:00
Jarek Kobus
fb50e35db9 FilePath: Fix hash function
For better performance, include also the scheme and host in qHash
calculation.

Change-Id: I2a69a128597429b88a71943d248ce038b49285f2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2023-05-05 13:40:31 +00:00
Eike Ziller
3ba769fb46 Fix saving of hardlinked files
Our atomic write involves writing a temp file and renaming that (which is
the only way to achieve something atomic). This creates a new inode, and
disconnects any hardlinks.

Note that the existing implementation for file paths with needsDevice
already keeps hardlinks intact, because even though it first writes into
a local temporary file it then writes the content directly into the
target with dd.

Check the number of hard links via system API and fallback to unsafe
writing if there are any, for desktop paths.

Fixes: QTCREATORBUG-19651
Change-Id: I3ce1ee81f339f241f0a2c9aa6f2259cb118ebef6
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-04-12 08:47:53 +00:00
hjk
305ccfe259 Utils: Replace FilePath::onDevice() by new FilePath::withMappedPath()
Basically a.onDevice(b) == b.withNewMappedPath(a), matching the order
of b.withNewPath(a).

Whether the (curretly docker-specific) path mapping is useful /there/, and
whether some of the calls are needed at all is dubious. I added some
FIXME and changed a few cases directly.

Change-Id: I7514736ce922f632f1f737bc496f6783389a42b6
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-04-04 06:56:55 +00:00
Orgad Shaneh
9956740905 FilePath: Optimize string compare in setParts
Change-Id: Ibc390ee943ed41dfef30fbbd07e2e681d82379ba
Reviewed-by: hjk <hjk@qt.io>
2023-04-04 06:14:12 +00:00
Tim Jenssen
adb664f521 Merge remote-tracking branch 'origin/qds/dev'
Conflicts: src/libs/utils/filepath.cpp
  src/plugins/qmldesigner/qmldesignerexternaldependencies.cpp
  src/plugins/qmlprojectmanager/cmakegen/generatecmakelists.cpp
  tests/unit/unittest/CMakeLists.txt

Change-Id: I017a6075db41a5233487ac855ffe23de2b2bb0ee
2023-03-30 13:30:42 +00:00
Tim Jenßen
feabda3aa7 Merge remote-tracking branch 'origin/10.0' into qds/dev
bigger conflicts resolved at:
  src/plugins/qmldesigner/CMakeLists.txt
  src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp

Change-Id: I08e2a109d8e37cbd77225129854e9e633725bfc7
2023-03-26 16:26:18 +02:00
hjk
b4bc5f6e1b Utils: Add short documentation for two FilePath functions
ensureWriteableDir() and createDir()

Also change a few \returns to Returns.

Change-Id: I8c80616a465a7e665ff56fab8279e43e5755fb4f
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2023-03-24 10:59:39 +00:00
Marcus Tillmanns
29873068eb Utils: Store Device::osType in settings
Change-Id: I41348be752598b7a8d1f1979764e7111cccc95a9
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-03-23 12:33:58 +00:00
Jarek Kobus
81bd8e3bd8 FilePath: Remove overloads for async tasks that don't take context
Passing mandatory context object clearly suggests a special
care should be taken for assuring the passed function
may still run when the task finishes in the future.

Fix FileStreamManager so that it deletes the streamer
even when context object was deleted in meantime.

Fix 2 usages of asyncCopy so that we pass a context object now.

Side note: passing nullptr as a context object is still
possible and should work, but it's not recommended.

Change-Id: I464438db42ed9292c2f89ecb9d5dde7c78f77640
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2023-03-17 14:30:59 +00:00
Jarek Kobus
44655995d1 FilePath: Provide overloads for async tasks taking context object
Change-Id: I0bb2f2bfc0f54e8a81efb7d9279d539bcdfd9bc9
Reviewed-by: hjk <hjk@qt.io>
2023-03-17 10:21:59 +00:00
Jarek Kobus
69fa8f3f3c FilePath: Integrate FileStreamerManager for async i-face
Change-Id: I3371471e3c23b86a62b5e4056b343941ab46e191
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2023-03-07 12:22:40 +00:00
Tim Jenssen
cc6c9e4b5e FilePath: fix documentation
Change-Id: Icd2ea0842279ac5ca9225b760aa7634b8db3e06d
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2023-03-02 11:28:26 +00:00
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