Commit Graph

120 Commits

Author SHA1 Message Date
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
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
Eike Ziller
2197eeb4aa Fix installation directory in plugin install wizard
Correctly initialize the bool variable that decides where the plugin is
installed.
Fix creation of installation directory: QDir::cdUp does not do anything
for directories that do not exist.

Change-Id: I5ee559a663380f293046eded7a2c3efbb1023776
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2021-02-15 08:30:47 +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
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
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
David Schulz
0bd85b00a7 Utils: export hash<Utils::FilePath>
fixes compile after 8683ec6a29

Change-Id: I1a3ef477e5f486a3222feeb17063e686b05e6277
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-12-18 10:06:50 +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
hjk
e109b731ad Utils: Rename FilePathList to simply FilePaths
The exact storage type does not really matter here.

Change-Id: Iefec40f0f5909c8e7ba3415db4a11962694e1b38
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-12-18 08:43:18 +00:00
hjk
d3b2c01c11 Utils: Move FileUtils::resolvePath to FilePath
In line with the general move toward use of FilePath nowadays.

Change-Id: I1c50e1479f7d9100ff8ded3ce3c22dd82b7fe6aa
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-12-05 08:38:03 +00:00
Cristian Adam
8ee22dd597 CMakeProjectManager: Fix clang code model when CMake PCHs are used
CMake gives the path to the cmake_pch.h[xx] file as relative path
to build directory. Making it absolute fixes the code model.

Fixes: QTCREATORBUG-22888
Change-Id: I2fdc080be779f22b737788be2074254290994aaa
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-10-22 08:12:26 +00:00
hjk
ddf0dd8734 Utils: Add a FilePath::isDir() convenience function
Change-Id: I1df0ee1b136299ae6e4f2e5bd0bdc24bfeca33dd
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-09-11 12:46:10 +00:00
hjk
e027ed5e96 Utils: Split FilePath::fileName
Into the regular case, and a fileNameWithPathComponents() function
handling the rarely used case with argument.

This saves a few cycles in the regular case and makes the function
usable by member function pointer in e.g. Utils::transform.

Change-Id: Ic4469198c3f8a44f59e50d70e67b864d876700d5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-08-14 09:40:24 +00:00
Frederik Schwarzer
4ca3bd4d0f check if Android sdk folder is writable
Fixes: QTCREATORBUG-21943
Change-Id: Ic20ed4c24c567b0b08269b7ad07014eb4248b214
Reviewed-by: hjk <hjk@qt.io>
2019-08-13 21:49:18 +00:00
hjk
a460fa3152 Utils: Register CommandLine
Needed e.g. in VCS support.

Change-Id: I3a9d64526bc0bf60a77ab154408dfec94cc6ba75
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-07-31 07:58:42 +00:00
hjk
44acfc0702 Utils: Drop transitional FileName alias for FilePath
Transition is over...

Change-Id: Iacaccead238130c8fdb347e172189ecc82b33401
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-07-24 07:31:50 +00:00
hjk
fa81f76237 Utils: Move meta char policy handling from FilePath to ConsoleProcess
Currently the only place that's using it and the scope is much smaller.

Change-Id: I1a43d14f0e2c69a16f76e6f83b82436bbeeac1c9
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-07-23 16:03:02 +00:00
hjk
8b72e92167 Utils: Add CommandLine convenience constructors
... taking a QString for the executable.

This weakens the very explicit QString -> FileName conversion via the
named constructors for the special case of constructing a CommandLine.

I think that's worthwhile here, as it reduces the noise on the caller
site under circumstance where the nature of the thing is obvious.

Change-Id: I27b4a73639728893d053b2e7ba65cb745f0ffe83
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-07-23 15:51:45 +00:00
Eike Ziller
5455234308 Merge remote-tracking branch 'origin/4.10'
Conflicts:
	src/libs/utils/consoleprocess.h

Change-Id: I771630cb4dc60a9e87e9d30d6295040c27348d8c
2019-06-20 11:03:05 +02:00
Eike Ziller
917636b88b Merge remote-tracking branch 'origin/4.10'
Conflicts:
        src/libs/utils/consoleprocess.h
        src/libs/utils/consoleprocess_unix.cpp
        src/libs/utils/consoleprocess_win.cpp
        src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp
        src/tools/clangrefactoringbackend/source/symbolscollector.cpp
        tests/unit/mockup/projectexplorer/project.h

Change-Id: I8d10f26b9bcb54829ba31cdc2272885691df1e16
2019-06-18 12:30:55 +02:00
hjk
611e1ea837 Utils: Encourage marking of raw command line parameters
Change-Id: Id66ac07732c66ab8c1232fe1f58042de8a61abb0
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-06-06 12:22:47 +00:00
hjk
772b48797d Utils: Add a CommandLine::splitArguments() convenience function
... and use it from within new SynchronousProcess functions
taking CommandLine arguments.

Change-Id: I5d7f83727cbb22f03b1a79b1645db95514c66033
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-06-06 08:42:06 +00:00
hjk
c7e2dc97e1 Utils: Pass an optional OsType parameter to CommandLine::addArg
... and extend the idea to addArgs(list)

Change-Id: Ia5423ee5ab96835b4adc23b72749e9c13892ee83
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-06-05 05:43:02 +00:00
hjk
959fec76dc Utils: Move CommandLine to fileutils.{cpp,h}
Causes less #include hassle when using downstream instead of
command/argument pairs.

Change-Id: I0fa0d016374df0b8e0a22f3786623652af684d36
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-06-03 12:32:07 +00:00
hjk
613d2e7d23 Utils: Remove rarely used FilePath constructor
Not much benefit interface-wise.

Change-Id: I0e605ec235e8072efcbf7e777cf7e8f8ee5e0799
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-28 14:05:51 +00:00
hjk
473a741c9f Utils: Rename FileName to FilePath
More in line with QFileInfo terminonlogy which appears to be
best-of-breed within Qt.

Change-Id: I1d051ff1c8363ebd4ee56376451df45216c4c9ab
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-05-28 12:23:26 +00:00
hjk
f7d224bf58 Utils: Remove now-unused FileName::appendPath()
Change-Id: I9d429a1f60930e27e3926e1242114bed3485f000
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-27 12:22:08 +00:00
hjk
535f0da977 Utils: Make FileName::shortNativePath a member
Change-Id: If1ab02ae9dc7efb97792cdf3bbdce3bba18b3e3d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-20 13:07:38 +00:00
hjk
c04370aa26 Utils: Make FileName::isFileNewerThan a member
Easier to discover and more compact in use.

Change-Id: I93dae0570a1dfded4d40dd6ae69b99fe82e3788f
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-20 13:06:06 +00:00
hjk
36daca80f3 Utils: Make FileName::canonicalPath a member
Change-Id: I8d7450dec5c4c14ae3e007d1d66f1a9c3c98f807
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-20 11:06:12 +00:00
hjk
c238fc88b1 Utils: Make FileName hold an QUrl optionally
This is meant to be helpful to piggy-back device information
in situations where the file resides on a remote file system.

The approach taken effectively duplicates the path data of the
url if the url constructor is actually used, but does not rely
on lossless path/fromPath conversions as it leaves the non-url
code paths unaffected in all situations.

The total overhead is deemed acceptable as the common use case
only default-constructs the m_url member which only sets a
pimpl nullptr.

Change-Id: Ie441cb1355ce086507333c31c7356ae5e6d10b96
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-17 08:35:18 +00:00
hjk
d1f9e466da Utils: Introduce a non-mutating FileName::pathAppended
... and start using it. The plan is to replace all appendPath() uses.

Change-Id: I555bcfa742b99b0951b98b0c0e707422c348fadb
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-15 11:45:24 +00:00
hjk
f99d69ee43 Utils: Replace mutating FileName::appendString
... by a non-mutating .stringAppended, doing the same.

Change-Id: I7adb6cae3415942cc9a80088bd75cda9d577d4a5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-15 07:42:59 +00:00
hjk
648f983f49 Utils: Use data member instead of inheritance in FileName
Change-Id: Ib0a9889dfa34ea877ee413881e87ab12c3a54956
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-13 14:57:49 +00:00
hjk
8b532c2cc5 Utils: Replace FileName::FileName(QFileInfo) by a named constructor
More consistent with the fromString case and avoiding false
conversions QString -> QFileInfo -> FileName in case the
inheritance of QString suddenly disappears.

Change-Id: Ib14646ab1a660fd45dd1ea6862a0b5faa52ad0e3
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-13 11:33:33 +00:00
hjk
dd304fc824 Utils: Remove FileName::isNull
... and its uses in order to shrink the FileName interface.

Change-Id: I4b9a229d98ad53c4f189e381c89241981ddbed2e
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-13 11:12:09 +00:00
hjk
88c495976c Utils: RemoveFileName::{size,count,length}
Use .toString().{size,count,length} instead.

Change-Id: Ib697155f441a8297fb179921bcd3397719a44073
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-10 12:36:27 +00:00
hjk
cf6421d3d1 Utils: Remove unused FileName::chop
It's unused, and non-const, so not nice-to-have in the url-using case.

Change-Id: I5ec7d06e74b20b22a2fd8467222a135a6dcce814
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-10 09:20:53 +00:00
Orgad Shaneh
24ec0b7708 Utils: Detect hardlinks also on Windows
Believe it or not, they exist :)

Git for Windows installs all its exectables as hardlinks for instance.

Logic copied from qfilesystemengine_{win,unix}.cpp in Qt.

This amends commit 118f713eb4.

Change-Id: Iafc64be4b2150378c7f9676fda0e01a43cd8b7cf
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-04-30 09:43:45 +00:00
hjk
4f3f73bc3b Utils: Rename one of the FileName::fromString overloads
Overloaded functions are ugly to use in algorithms like transform().

Change-Id: Ia4f191e1cd9a21ceb99dec23a8f4fd1ce5f24182
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-03-19 09:05:47 +00:00
Ivan Donchevskii
7f67e987ea CompilationDatabase: Add folders to Project view
Change-Id: I4cd480535c203aa923b27596ea4ca74f83c12a9e
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-11-05 15:51:12 +00:00
Alessandro Portale
f6943a712a Utils: Modernize further
Many issues, mostly in headers, were not addressed in
e38410b76c

modernize-use-auto
modernize-use-nullptr
modernize-use-override
modernize-use-using
modernize-use-default-member-init
modernize-use-equals-default

Change-Id: I320a51726db881e582b898948d53735ebb06887a
Reviewed-by: hjk <hjk@qt.io>
2018-07-24 12:21:42 +00:00
Andre Hartmann
85ffe78e96 Utils: Properly name withNtfsPermissions()
Change-Id: I759e702b63f8bed9384ccbfae6345f858e50830b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-06-05 12:59:56 +00:00