Commit Graph

195 Commits

Author SHA1 Message Date
David Schulz
3b127c04e8 Utils: add rename function to fileutils
Change-Id: Iaf47744819c21013661e3bd0275a04c1d68e9023
Reviewed-by: hjk <hjk@qt.io>
2021-06-17 06:35:40 +00:00
hjk
e3c03fd3c5 Utils: Implement FilePath::writeFileContents()
Including a docker version of it.

Change-Id: Ib2ac6073cc2b39818fb77a7d9d608386f9d17285
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-16 09:00:37 +00:00
hjk
31dd9c87f8 Utils: Make FileUtils::copyIfDifferent work also with remote paths
Also really check contents if file dates are equal.

Change-Id: I39fca67b3616e931f1ed11d002fccaa232a0d74d
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-14 11:20:15 +00:00
hjk
a5b16f8137 Utils: Support remote FilePath::{lastModified,{remove,copy}File}
And implement the Docker variant.

Change-Id: Iee7cd0aaaf3d5c7dbb4ff995ac6889f31cb2f505
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-14 11:19:31 +00:00
hjk
e35235ea72 CMake: Collect also remote filenames from generateBuildTargets()
QDir::cleanPath(...) doesn't do the right thing on stringified
Utils::FilePaths. Use FilePath functions instead.

Change-Id: Ied66f38dd30a15694bce12ed57d37411bb87f680
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-14 08:43:45 +00:00
hjk
ef730d5ffb Utils: Introduce a FilePath::cleanPath
Change-Id: I8ce1aaf3e6b118f28414e7a52a1b310dd81e75e3
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-11 08:38:37 +00:00
David Schulz
4465fd06ae Utils: add home FilePath convenience function
Change-Id: I5d0d695dc127090be4323fac6ff4ef2b1729cb92
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-10 11:47:14 +00:00
hjk
09ead204ea Utils: Improve FilePath::parentDir() for the remote case
QDir::cleanPath() should not be used on FilePath::toString'ed
object, it removed the second slash in the :// separator.

Change-Id: I0168d52f6d7caa99f5ccc5d1d93ae2bd783332c5
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-10 05:59:31 +00:00
hjk
18245dcf10 Utils/ProjectExplorer: Add IDevice::searchInPath
Change-Id: Ibc7cc7bd6bf3a7776681f7cd2fff051525b19f60
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-10 05:05:58 +00:00
David Schulz
0cfe27a53d Debugger: filepathify DiagnosticLocation
Change-Id: Ibbbf137231b313ec10e3d57c0230217b0c1e0a6c
Reviewed-by: hjk <hjk@qt.io>
2021-06-09 06:57:42 +00:00
hjk
b820a832b2 Utils: Add a FilePath::lastModified() interface
And a local implementation.

Change-Id: I26400d960890c1cfb3daf82e6bfdeffa68455471
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-09 06:38:11 +00:00
hjk
a7cd9bda3a ProjectExplorer: Implement (Docker)Device::exists(filePath)
While the original plan was to use more specific functions like
'isReadableFile' to cut down the number of accesses, it is
unrealistic to re-write all occurrences in reasonable time.
So make the basic building blocks accessible, too.

Change-Id: I2586ebd19e1e7ae2c884fd2a4180869421293e3a
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-07 12:16:38 +00:00
David Schulz
aa8d2dc2d1 Utils: add FilePath::(complete)suffix
The same as FilePath::(complete)baseName avoid some toFileInfo.

Change-Id: Id1901ce2a4bef675215a9e020280df1c846df405
Reviewed-by: hjk <hjk@qt.io>
2021-06-04 09:32:52 +00:00
hjk
93ca1a87a5 Utils: Somewhat improve remote FilePath::canonicalPath()
At least keep the remoteness.

Change-Id: I80c865d7b5c7d2dbca6ea6c4c269ef144a7d144c
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-04 07:42:37 +00:00
David Schulz
5ec611b68e Utils: add FilePath::completeBaseName
Removing some FilePath::toFileInfo() calls again.

Change-Id: I6610beebf2c30754fde525b71f4c4a34ceb5e30b
Reviewed-by: hjk <hjk@qt.io>
2021-06-04 07:07:07 +00:00
David Schulz
068873c9d5 Utils: add FilePath::baseName
Removing some FilePath::toFileInfo() calls

Change-Id: I49be2ef260f225e07b64ee8ace6a8cd47a9d8bb2
Reviewed-by: hjk <hjk@qt.io>
2021-06-03 11:23:35 +00:00
hjk
c2bc7b8d3c Utils: Introduce FilePath::ensureWritableDir()
Combine the test and potential creation in one operation to potentially
reduce the number of remote calls.

Change-Id: I06ffa1256593afec430eb35605ba3b249f1da97c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-01 14:24:52 +00:00
hjk
41240ed706 Utils: Differentiate between WritableDir and ReadableFile
Brown paperbag.

Change-Id: Ice4e3760bbfc5699f7efef49919505657d731867
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-01 08:09:28 +00:00
hjk
3b87c1e44e Utils: Make FilePath::relativeChildPath() work with remote paths
Change-Id: Ie8f3c932714afb5c47236165acda703691cc5cab
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-20 09:20:30 +00:00
Cristian Adam
de9be2bb9d Only define CALLBACK when PCH is used
The PCH header is undefining CALLBACK after loading Windows headers,
but we need to add it back when using Windows headers that need it.

The new definition needs only to be done when the PCH is used,
otherwise it could lead to re-definition warnings.

Amends 7880950eca

Change-Id: Iae57ac4bbbfdd45b5f9b50a2242103bec6eea5bc
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2021-05-19 14:51:59 +00:00
hjk
2e2d1835d1 Utils: Make FilePath::operator+() work with remote paths
Change-Id: I1f0963b4da8c000fa1ea709d358490cb8f986ee5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-19 13:02:13 +00:00
hjk
a71bb36682 Utils: Centralize FilePath case sensitivity handling
This could or possibly should the target device's file name case
sensitivity into account by diverting to IDevice. However, as this is
expensive and we are in time-critical path here, we go with "good
enough" for now.

The first approximation is "Anything unusual is not case sensitive"
which is better than "Any device equals the host".

Change-Id: Ib3d4a627abebd96a7285a855af66e0c800767767
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-19 13:02:05 +00:00
hjk
2db9ebc615 Utils: Rework FilePath guts
This replaces FilePath::m_url by explicit host and scheme members

This removes the unclear duplication of information in m_data and
m_url.path() and avoids syntactic restrictions a real url has on
scheme and host and complex (and potentially lossy) url parsing:

    QUrl url;
    url.setHost("1234");
    assert(url.host() == "0.0.4.210")

The toString/fromString methods now accept strings of the form
scheme://host/path, mimicing the use of urls so far.

Relative remote paths are representable, their toString() output
looks like scheme://./host/path and can be parsed back by fromString().

Change-Id: Id3b52c270b228e23834faa3f44daad8b1718b654
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-19 11:41:42 +00:00
David Schulz
7020d54a0a Utils: add absoluteFilePath convenience function to FilePath
Change-Id: I870c3e8fce908d3c5830d2716b525cb12b701503
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-19 09:45:16 +00:00
David Schulz
a13aef759e Utils: filepathify fileutils
Change-Id: Ic9048369f64d793f5f567cdb0c715488fb5a4ff6
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-18 14:30:53 +00:00
hjk
3d092b8c28 Utils: Show remote FilePath also on qDebug
Change-Id: Ic437279115a7393c6bea4f84db6e0e5552c22d31
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-05-17 13:23:45 +00:00
Eike Ziller
f18ac508e8 Move CommandLine out of fileutils.h
to ProcessArgs and rename the files to commandline.*.
fileutils was a strange place for CommandLine, and this
reduces the dependencies needed for sdktool.

Change-Id: I9d7e8ffe8a3560f5d12934457b086f9446976883
Reviewed-by: hjk <hjk@qt.io>
2021-05-11 13:27:23 +00:00
hjk
9877460dd6 Utils: Move ProcessArgs class into filepair of its own
There's not much interaction between ProcessArgs and QtcProcess
and both .cpp are still quite big, with non-trivial bits.

Change-Id: Id84202f6c34057bf87cc8f27fbb45f78f105e9a5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-11 12:14:52 +00:00
hjk
f2f40efa03 Utils: Move process arguments class out of QtcProcess
The main QtcProcess interface is nowadays a CommandLine, with no
explicit references left to QtcProcess::Arguments and related static
helper functions, so it only clutters the QtcProcess class interface

So move these items out of QtcProcess, later potentially to a separate
file pair.

Change-Id: I45c300b656f5b30e2e2717232c855fdd97c2d1d7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-11 09:45:24 +00:00
Andre Hartmann
9e9bd383bc FileUtils: Simplify statement
Change-Id: I9db62241c81c2ffc25c2caa34524e4c98ef01ed1
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-10 13:18:11 +00:00
hjk
7f61347757 Utils: Add some description of FilePath::onDevice
Change-Id: I92f2a9b387b026e128b5a733211aec0d9c443d4f
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-05 13:42:28 +00:00
Cristian Adam
7880950eca PCH build fix when building with Clang 12
Clang 12 has added a template parameter as "CALLBACK",
which conflicts with the Windows "CALLBACK" define.

Change-Id: I773899d103dcb1a852b555a1900b2de4acb6d96f
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2021-05-02 11:38:01 +00:00
hjk
d9862a767b FilePath: Prepare for implementation some remote functions
The callback will be set from DeviceManager to re-route the
implementation through matching IDevice instances.

Change-Id: Ib210504008b8a3471452448a98378d4902e2cadf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-04-27 13:00:59 +00:00
Eike Ziller
c1f90aeca2 ICore: Change some path API to use FilePath
Change-Id: Id841d6177206a021c9e606ce560b47d1ae6e52b9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2021-04-26 08:03:47 +00:00
Eike Ziller
b264770e17 FilePath: Return QString copy from toString()
Returning a const reference is different from our usual coding style,
and can lead to crashes when assigning to a const reference, like

const QString &path = filePath.pathAppended("foo").toString();

Make it behave like our other API.

Change-Id: Iab1cf1a944be405227b135c12029f58869893911
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-04-26 07:00:47 +00:00
Jochen Becher
05324cf21f Extend Utils::FilePath for relative paths
The new methods allows converting a path to a file or directory into a
path relative to another path to a file or directory.

Change-Id: I8c743d5bced9fec81b05ce94ac2b7bec307d9028
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-04-19 04:55:54 +00:00
hjk
ef25cfac59 Utils: Do not add extra space for user display of command lines
... that do not have parameters.

Change-Id: I2ea20267bc18826e4017a356f6bc13f4b0172f3c
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-03-16 03:36:04 +00:00
hjk
32394632d2 Utils: Add CommandLine::addArgs(const CommandLine &cmd) convenience
This adds cmd's executable and arguments one by one to this commandline.
Useful to construct command lines for 'sudo', 'nice', etc.

Change-Id: I76067bc10e269b8e7ff4d945449be3633b321281
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-02-16 12:53:55 +00:00
Eike Ziller
27300c66fe Improve plugin install wizard on macOS
Downloaded files get a quarantine flag on macOS, which prevents loading
them as a plugin in Qt Creator. Remove the quarantine flag when copying
the plugin.

Change-Id: I3edef3ddfbab299be750e728a9fac0536634ba1b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-02-15 14:10:17 +00:00
Cristian Adam
98b92ed03e CMakeProjectManager: Fix issues with precompiled headers
Clang code model can break if CMake project uses precompiled headers.

QtCreator will make a copy of the precompiled header, this way it
will not conflict with the build system one.

Ammends 888ea6bbbb

Fixes: QTCREATORBUG-24945
Fixes: QTCREATORBUG-25213
Change-Id: I149fc416cd047683d095758a024de47c7baf681c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-01-14 08:08:40 +00:00
Eike Ziller
7496136992 Utils/copyRecursively: Avoid copying of copy helper instance
The function took a const reference to a std::function. When passing
some other callable object, this leads to a copy, which is bad if the
callable is supposed to carry along state.

Change-Id: Iedc22644fb0f314b15de0eaaa7c0b2e73dd30f38
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2020-07-13 08:20:40 +00:00
Orgad Shaneh
51453936cc Utils: Replace foreach with range-based for
Change-Id: I9aeea9c029ffc56cbadc04edd20e9b35b154f986
Reviewed-by: hjk <hjk@qt.io>
2020-06-16 04:43:29 +00:00
Eike Ziller
7cedde2a0a Utils: Create re-usable Callable for copying and asking for overwrite
FileUtils::copyRecursively has the option to override the copy
operation, and this is e.g. used for asking the user if files already
exist, and to track what is actually copied.

Make that functionality available for re-use.

Change-Id: I16b7eddd32509b06866a1070e45ab58629f9a9be
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-06-15 07:43:59 +00:00
Eike Ziller
aa2aa9bf2a Merge remote-tracking branch 'origin/4.12'
Change-Id: Id1c063ae716c3acf5e6201c15663637040aa9a35
2020-06-03 12:22:18 +02:00
Christian Kandeler
4a6aa35a91 Utils: Do not use QDir::cleanPath() in FilePath::fromUserInput()
Some of the functionality of QDir::cleanPath() breaks the use of
Creator's variables. For instance, "%{sourceDir}/.." becomes ".".
This has hit us before; see commit 8bc7e04012.
It's not always possible to expand strings before converting them to
FilePath, and it would require a lot of work to change all occurrences
of potentially unexpanded FilePaths to QStrings, so it seems like the
more practical solution to allow unexpanded FilePaths.

Fixes: QTCREATORBUG-24095
Change-Id: I5fbbd181cb888b129f11c120e363228bc52b090a
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-05-29 11:40:54 +00:00
hjk
13ad816308 Utils: Use QRegularExpression in fileutils
Change-Id: I48b192630e52ff3825bcb401a19faef59e846da3
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-05-27 12:01:38 +00:00
hjk
021cab2048 Utils: Introduce FilePath::operator/(const QString &)
Including some random uses.

This mimics  std::filesystem::operator/(std::filesystem::path).

Change-Id: I0b0f5cf0d962fd33d4cbb9be96645a0b4a21ee03
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-04-09 07:48:22 +00:00
Christian Stenger
798b2674af Debugger: Fix go to location on interrupt
Avoid checking an invalid QUrl - instead restore
old code of always creating one an verifying this
instead.
Remove the now unused FilePath::isLocal().

Change-Id: I037c43e6fbdb7dc1f8901fc70b581f3c94ab503a
Reviewed-by: hjk <hjk@qt.io>
2020-01-31 13:18:50 +00:00
hjk
711daa3803 Utils: Introduce a FilePath::absolutePath() function
... and start using it.

Change-Id: I44c74005a4deee72d0332106a4ce3582e0b66191
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-12-19 07:59:30 +00:00
hjk
8683ec6a29 Utils: Move std::hash<Utils::FilePath>::operator() out of line
This generates quite a bit of code, and the non-inlined call
should not be noticible given the rest.

Change-Id: If3a699737142c2953dd0977df850b07bc529a124
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-12-18 08:52:30 +00:00