Commit Graph

166 Commits

Author SHA1 Message Date
Christian Stenger
34b7ef6bb3 Utils: Fix recursively copy
Amends 2ab2d96753.

Change-Id: I93467174134b9e1372a5565f429a8cb8334413f8
Reviewed-by: hjk <hjk@qt.io>
2021-08-10 08:16:00 +00:00
hjk
2ab2d96753 Utils: Use FilePath in copy helpers
Change-Id: I81b367a5851c0fbcdf45c63c5536c206845a8337
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-10 07:19:10 +00:00
hjk
2b820cc42d Utils: Fix Coverty complaint
Change-Id: I69067a24e8c739f3e2241d06a3b4344a37b409c6
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-08-09 06:22:14 +00:00
hjk
764bf7396c Utils: Introduce FilePath::fileSize()
And implement it locally and for docker.

Change-Id: I362f4cae95560836d9300473a286429eb4569329
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-07-27 08:19:43 +00:00
hjk
3edc5673b5 Utils: Provide FilePath based wrappers for common dialogs
Change-Id: I464a7b5775495f32648905335f2d798384867900
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-26 09:44:20 +00:00
hjk
fd677101a9 Utils: Split FilePath off fileutils.h
This now rather central class deserves a suitably named file(pair).

The rarer used declarations including otherwise not needed includes are
still in fileutils.h.

Change-Id: Ib18d72f16322c03f76023fdefcd5f6da35311b8b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-22 11:52:58 +00:00
hjk
1c3b9e2bfe Utils: Remove unused function FilePath::resolveSymlinkTarget()
Change-Id: I7687f094a1e8054ac8298be754e95252db64c022
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-21 14:05:51 +00:00
hjk
486fd8f7d6 Docker: Implement fallback for DockerDevice::directoryEntries()
Change-Id: I57430bc4cf79abfc07ccbe06746a0857e10053da
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-16 14:37:15 +00:00
hjk
1bde4ddbec ProjectExplorer: Use FilePaths in project tree nodes
Change-Id: I31b15c428d9b962333947b1e32641fd80f61d069
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-16 13:45:06 +00:00
hjk
d06c670504 Utils: Introduce a FilePath::withNewPath() convenience method
It's effectively the mirrored version of onDevice() with an
equally odd name which is a bit more straightforward to use
in some cases.

Change-Id: I0cfedeb58871a857c93144e2a0d734bad1bcd887
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-16 11:13:14 +00:00
hjk
e8521e6fe1 Utils: Add/fix FilePath::isFile and FilePath::isDir
In general, the more specific isReadableFile etc are preferred, but for
porting a 1:1 match to QFileInfo functionality is helpful.

Change-Id: I5b575ca9a5053f13f63c0fbe0e3dcc222494280f
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-07-14 08:16:57 +00:00
hjk
97578a4fee Utils: Allow an offset in FilePath::readContents()
Also, change the size limit to take a qint64. Contrary to e.g.
Q(6)Hash::size() there is a realistic chance that 31 bits are not
enough.

Change-Id: Idbe6e765a5cac4336b3d64a8e0adb14966fd18a3
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-09 12:48:37 +00:00
hjk
05545adb93 Utils: Change semantics of FilePath::onDeviceSearchInPath()
... and rename it to searchOnDevice().

We need to handle additional search directories anyways, so its more uniform
to always pass a list all of them.

Change-Id: I46c7860b51d11c26db58045ff3ab922148af021f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-08 10:28:49 +00:00
hjk
d7062b5b92 Utils: Allow additional directories for FilePath::searchInPath
This mimics Environment::searchInPath().

Change-Id: I8c772ed31c31c74b09c7aa0e4912de8586dd2468
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-07 10:43:46 +00:00
hjk
eb70e20453 Utils: Add a FilePath::environment
A hook into the system environment of the FilePath's device.

Change-Id: I274032f9e716f3cd8b2e4af2eca010b9805a4568
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-07 07:22:30 +00:00
hjk
2bf72a6dfd Utils: Move resolveSymLinks from FileUtils to FilePath
And make it work with remote paths.

Change-Id: I1fe4548547231338284152a86c43f5d0b1eba4d6
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-02 11:08:00 +00:00
hjk
9287b1a3be Utils: Introduce FilePath::is{Relative,Absolute}Path
To operate correctly with remote target files systems that do not
match the host OS.

Change-Id: Ia4ea284dc38399deacb50410c9618e1e139f4e13
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-07-02 06:29:12 +00:00
hjk
4ba07d05c4 Utils: Make a FilePath's osType publicly accessible
Will help with proper is{Relative,Absolute}Path implementations.

Change-Id: Icad90b5a55d9cf733f6ee66dbbe273ec9682d387
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-07-02 05:36:36 +00:00
hjk
92904480f0 Utils: Merge FileUtils::removeRecursively() into FilePath
This simplify the interface by removing a possibly wrong choice
ensures it works also on remote paths.

Change-Id: I01e198958900a91b99dcf2dbb491a593485493ba
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-07-02 04:57:24 +00:00
hjk
a2790ac95b Utils: Implement FilePath::withExecutableSuffix()
Change-Id: Ibf6919991b229eb91953b3c5b5cbb75a1be7ff5d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-30 13:24:59 +00:00
hjk
4a8c222c18 Utils: Add FilePath::symLinkTarget
And implement it for the docker device.

This replaces the previous unused and not really implemented
FilePath::resolveSymLinkTarget.

Change-Id: I9dcb4f8276dbb88b21959276da0d50135742fba0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-30 11:11:10 +00:00
hjk
b8e6d05ded Utils: Also pass Sort flag to FilePath::dirEntries
Change-Id: Ic21c2ba3ef59c6bb3e19552904187b3c6a096d80
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-29 13:16:46 +00:00
hjk
1e1c556bc8 Utils: Add a FilePath::ensureExistingFile
Essentially a kind of 'touch', to be used in the CMake file API.

Change-Id: Iaae62b441c0006b39d4bef5f06420e798c28c2a5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-29 12:34:43 +00:00
hjk
5ead2afeeb Utils: Implement FilePath::removeRecursively
Sprinkle a few QTC_ASSERT to make sure we are in a known
context.

Cmake's FileApiReader uses this before moving directories
as QFile::rename does not do anything if the target exists.

Change-Id: I555f99e81a9fe7d93ae66145eeebfa9d5880bc51
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-29 09:34:28 +00:00
hjk
54b4022987 Utils: Implement FilePath::rename()
And uses it in CMake's fileapi reader.

Change-Id: I9e719aa4b253eaca17c6b304eab5e7268fcfab29
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-28 13:03:32 +00:00
David Schulz
6902ddc535 Utils: add FilePath::isWritableFile
Change-Id: Ic6ced87fcee92deadf5a117ea7e987f1c877f83a
Reviewed-by: hjk <hjk@qt.io>
2021-06-23 06:21:46 +00:00
David Schulz
b099d98a17 Utils: add permissions() to FilePath
Change-Id: I89082550a4f053c400d13a34df4f9c09c65bc326
Reviewed-by: hjk <hjk@qt.io>
2021-06-17 09:31:09 +00:00
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
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
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
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
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
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
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
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
Eike Ziller
768d4321f9 Merge remote-tracking branch 'origin/4.14'
Change-Id: I214b8d59e8ff7fe0511cd6116ec7725ddc4376ee
2021-02-18 09:26:22 +01:00