Commit Graph

59 Commits

Author SHA1 Message Date
Marcus Tillmanns
a1a6ccbf1c Utils: Add FilePath::watch
Change-Id: I1e5706f22aaa072c68b97496896cfa6d244d9849
Reviewed-by: hjk <hjk@qt.io>
2024-06-21 05:18:16 +00:00
Marcus Tillmanns
1c905c6980 Utils: Shortcut File reading
If the device can point us to the local equivalent of a file we can
read that one instead.

Change-Id: I002b5babae13677d5814b639ca40a62f23a8b374
Reviewed-by: hjk <hjk@qt.io>
2024-04-09 05:32:36 +00:00
Eike Ziller
5af531cd39 Utils: Fix build with MSVC with C++20
Rename process.h back to qtcprocess.h

MSVC's "threads" standard header includes <process.h>, and that ends up
including our process.h from Utils.

There already was a hacky workaround in place for a similar issue with
MINGW, but that doesn't work with MSVC because that doesn't have

Simply use a name that doesn't conflict.

Change-Id: I1159cd2096b4f2dbc4a1728d0131dd6edd30ebd3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2024-02-28 08:09:05 +00:00
Eike Ziller
a8414effd8 Merge remote-tracking branch 'origin/13.0'
Change-Id: If752e3383b35873b696e8beca27d8838a4096c8a
2024-02-27 09:04:51 +01:00
Eike Ziller
462caec278 Utils: Small string fixes
Change-Id: I2fd6bf14b1cb35f61ced841e3deea011fd54ff03
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2024-02-26 08:56:41 +00:00
Marcus Tillmanns
0aa54364f8 Utils: Remove offset parameter from writeFileContents
It never worked and was not used, so remove it for now.

Change-Id: If271bf83e1c766cc31fdb24dbab9eac228fda0a2
Reviewed-by: hjk <hjk@qt.io>
2024-02-22 12:02:09 +00:00
Marcus Tillmanns
e8ad29d3af LinuxDevice: Add disconnected state
Change-Id: Ic2c909e3375a9fb025a335c1ca65621fa031d000
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2024-02-13 11:49:47 +00:00
Jarek Kobus
290121bc21 Process: Use more rawStd{Out,Err} const methods instead of mutable ones
Avoid using readAllStandard{Output,Error} mutable methods if possible.
Use non-mutable methods when we are not connected to
readyReadStandard{Output,Error} signals.

Change-Id: I2e830e571b9eab2177fd856bbe06dfc5137d9c01
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2024-01-21 17:21:25 +00:00
Tim Jenssen
435761fd0a Merge remote-tracking branch 'origin/qds/dev'
Change-Id: Ieb14c6311dbfe828a94981854b9ec8c18182b6cd
2024-01-05 14:18:18 +00:00
Tim Jenssen
506ff2eea7 Utils: add more removeRecursively checks
Change-Id: I0b8bbe99132157cc5a73355c9b396201ec259aaa
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2023-12-21 12:13:15 +00:00
Jarek Kobus
24397509d4 Libs: Cleanup lambdas
Change-Id: I715a124dd73f23c735dde27d3205ac7613ae04c6
Reviewed-by: hjk <hjk@qt.io>
2023-12-12 11:28:30 +00:00
Marcus Tillmanns
437797d1c4 Utils: Fix endless loop when ls iterating subdirs
findUsingLs did try to enter "." and "..", with especially "." leading
to an endless loop.

findUsingLs also did not correctly concatenate the parent folder
for sub directories.

Change-Id: Ieafad4d4ef38d2fb550ddef1d2edf8183ce8032e
Reviewed-by: hjk <hjk@qt.io>
2023-11-07 14:20:33 +00:00
Eike Ziller
8f3e77a3ae Tr: Re-fix plurals
The number for the plural must be given as the 3rd argument
to the tr() call, not as an arg().

Amends 1359e9c84f

Change-Id: I45241a6acd82041c320bbe476cd2b4cc92247ef3
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-10-18 11:22:11 +00:00
Eike Ziller
1359e9c84f Tr: Fix some plurals
Change-Id: I9d7a52a64536e6e1c0a9da4f3cb2f3a116afb6cd
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-10-16 13:19:28 +00:00
Eike Ziller
13fa7703a4 Merge remote-tracking branch 'origin/11.0'
Change-Id: I6c2a1d497aae9bda45c4aae47fb0be6c61c1ec29
2023-08-23 09:30:32 +02:00
Marcus Tillmanns
3024c1314e Utils: Speed up isDirectory for roots
Change-Id: Ic369bb1b6a5deb84f0da38af7e71d51139a67c9e
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-08-22 13:28:16 +00:00
Marcus Tillmanns
39837d9c26 Utils: ensureWritableDir returns expected_str
Allows calling code to get better feedback to user.

Change-Id: I6d11787d314921dc052e87a8348683b221a17425
Reviewed-by: hjk <hjk@qt.io>
2023-06-22 08:23:33 +00:00
Marcus Tillmanns
e0bdec5fcf Utils: Fix remote ensureWritableDirectory
Previously ensureWritableDirectory would return true even if the
directory existed but was not writable. This patch fixes that.

Change-Id: I3c97ecb22eae7d77bf1d44b13b22d81ba2529062
Reviewed-by: hjk <hjk@qt.io>
2023-06-20 13:01:24 +00:00
Orgad Shaneh
a5dfbe01d5 Utils: Support hardlink detection also on Windows
Change-Id: I717899ef73e965438ecd28983397ffc90a7ff570
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
2023-06-02 11:25:54 +00:00
Eike Ziller
6e7bb28f09 Tr: Add missing full stops
Change-Id: I2debc56d0740eaa30c7d597eae18910f319c1d98
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2023-05-26 13:50:18 +00:00
Eike Ziller
f2c1455025 Tr: Wrap file paths with ""
Change-Id: Iee0e941ff503ff485e8e9c0d9fe3e52eea9042d5
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2023-05-26 13:50:07 +00:00
Björn Schäpers
b8a82d824b Utils: Fix unused parameter warning
Change-Id: Ibe4c866b4f3bf39999cfe43bd32287e069e51d2c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-05-11 19:06:21 +00:00
Jarek Kobus
a0f6e8dc04 Utils: Rename qtcprocess.{cpp,h} -> process.{cpp,h}
Follows QtcProcess -> Process rename.

Change-Id: I97235a9a40cb7fd52944515b7ab878d96528f919
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-04 05:52:26 +00:00
Jarek Kobus
470c95c94b Utils: Rename QtcProcess -> Process
Task-number: QTCREATORBUG-29102
Change-Id: Ibc264f9db6a32206e4097766ee3f7d0b35225a5c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2023-05-04 05:52:16 +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
663bbbfb0e Utils: Also list dot files when using the ls fallback
Change-Id: I6763280134e8cb040b6bc627b4f67d595dc2fb5e
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-04-05 09:44:10 +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
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
Marcus Tillmanns
e093c39727 Utils: Better error reporting for copyFile
Change-Id: Id76280e83e9dae92bff2db5722f1e582867e1566
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-03-14 14:40:53 +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
Marcus Tillmanns
1d6c161124 Utils: Fix missing modeBase
Change-Id: I8ce9393ef97b83b9db8cde12cc8653e9072dad65
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-03-03 14:24:25 +00:00
Marcus Tillmanns
c41d30711a Utils: Make UnixDeviceFileAccess macOS compatible
"stat" on macOS has slightly different formatting options.

Also adds unittests for UnixDeviceFileAccess

Task-number: QTCREATORBUG-28142
Change-Id: Ib42fc1c22ef2771365e915df34f2286e2c705568
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>
2023-02-25 09:45:47 +00:00
Eike Ziller
012a2a6cd8 Fix build on Windows / MSVC 2019
Change-Id: I265cd316426c76c76bfe18a62a9e5f35fbca3da9
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-02-08 07:28:59 +00:00
Orgad Shaneh
f94b41313b Utils: Fix MSVC size_t -> int warning
Change-Id: I2732f7b9ad3c7ae96d2d213822f05f37dfcac0aa
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-02-08 06:46:30 +00:00
Marcus Tillmanns
96185ca4f1 Utils: Use QtcProcess in FilePath::fileContents
Change-Id: Ia7236632c6d9b887d054a3254762b7e3592e73e1
Reviewed-by: hjk <hjk@qt.io>
2023-02-07 13:55:31 +00:00
Marcus Tillmanns
9d6b3b4cb4 Utils: Remove status= when using dd
Some versions of dd don't support the status= option.
(e.g. the dd version in boot2qt)

Change-Id: I22aa6571b223b7707e962bd2df9abdd11b438d69
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2023-02-07 11:15:49 +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
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
David Schulz
0dab651ccd Merge remote-tracking branch 'origin/9.0' into 10.0
Change-Id: I7e171601cd7317b48d5074bbc0ead127813d596c
2023-02-01 08:16:30 +01:00
Marcus Tillmanns
598ffc3b1c Utils: Fake root info
When trying to open a FileDialog all roots were tested for existence.
This is slow and might show ask-pass.

Since "/" can be considered always valid, we create a fake entry for it
and only test existence of remote paths if they are not a root path.

In the future FilePath should get a "isRoot()" function so we don't just
test for == "/".

Remove the fileAccess from WebAssembly devices.

Change-Id: I7a1a6e7d2025e9fd4428e4bd1d07cdbdb5680c8e
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-27 11:13:58 +00:00
Marcus Tillmanns
94dd5a157b Utils: Let copyRecursively create target folder
Previously FileUtils::copyRecursively did create the target folder,
FilePath::copyRecursively now does the same.

If either src or target are .qrc paths, select the fallback copy
routine, as tar cannot read or write to a .qrc folder

see: 7cb74e325f for report about
failing test in testProject_multipleBuildConfigs

Change-Id: I52bb9ad8f018f359f598e5bc8b18ab31c901496f
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-01-26 08:23:19 +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
Jarek Kobus
398b5656b4 Utils: Use multi-arg for strings
Change-Id: I57d87b8f0435c7b304c484ad4d728b59780f212d
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-01-11 11:03:23 +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
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
ca6b14cf01 ProjectExplorer: Funnel environment fetching through device access
Easier nowadays. It's synchronous now, so conceptually worse,
but 'env' is not worse than 'ls', and this is used regularly
all over the place also for larger data sets without being a problem.

Change-Id: I2c2b1db8c07ff5c128700d4a1deefd710967568a
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-12-15 14:17:36 +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
Jarek Kobus
36be7b8375 Utils: Don't call mutable expressions inside QTC_ASSERT
In order to conform to the theory: "Removing all
QTC_ASSERTs and QTC_CHECKs should not change anything".

Change-Id: I6f5c4486afb422301562d79c662fdde026e4d788
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-12-09 08:10:17 +00:00
hjk
3537c9974e Utils: Use .path() instead of .toString() in some local cases
Same effect, but "better" conceptionally.

Change-Id: Ic33bdc097b38176e81413736b2eb44d1fb7d0a3f
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-11-29 10:10:27 +00:00