aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/fileutils.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Revert "ProjectExplorer: Let user choose a directory with "load project""Christian Kandeler2025-10-311-44/+8
| | | | | | | | | | Even on non-Windows systems, files can only be listed, not selected in the dialog, when using QFileDialog::Directory. This reverts commit 8b0bbcbf09d0081b42928721be911ef8238e59e3. Change-Id: Iaf34ce7186306f26f157b05d14e73d1834797d60 Fixes: QTCREATORBUG-33697 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* ProjectExplorer: Let user choose a directory with "load project"Christian Kandeler2025-10-241-8/+44
| | | | | | | | | | Analogous to what we support on the command line. Not available on Windows, as the file dialogs for files and directories are mutually exclusive there. Fixes: QTCREATORBUG-33654 Change-Id: If5e0c940c4b9377da0cefe5b0c65ab7dc9796ad7 Reviewed-by: David Schulz <david.schulz@qt.io>
* Utils: Use a Result<> for FileUtils::copyRecursively()hjk2025-08-271-28/+26
| | | | | | | | Api: bool FileUtils::copyRecursively(..., QString *) -> Result<CopyResult> FileUtils::copyRecursively(...) Change-Id: I4073f52d87fdeef3df3510afbcac61058fd46acc Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
* Utils: For non-native QFileDialog when the basedir is remotehjk2025-08-051-1/+1
| | | | | Change-Id: I29d3924d48bdb94ee2fab4c5fc98024d2fb7bcf7 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
* Utils: Introduce FilePaths::commonPath()hjk2025-07-141-46/+2
| | | | | | | | ... and deprecate the two FileUtils::commonPath overloads, one of which isn't actively used anymore. Change-Id: I3a407b24d147afe30e93b04108ae7377a0120684 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
* Utils: Make FilePaths a full class instead of a QList<FilePaths> aliashjk2025-07-111-1/+1
| | | | | | | | | | | | | Creates a natural place for named constructor and conversion functions. Api: Created Utils::FilePaths as full class instead of a QList<Utils::FilePaths> alias Api: Utils::FilePath::fromStrings -> Utils::FilePaths::fromStrings Api: Utils::FilePath::fromSettingsList -> Utils::FilePaths::fromSettings Api: Utils::toFilePathList -> Utils::FilePaths::fromStrings Change-Id: I1786519206dd1fb68f410d54ce77a0846dc1f9de Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Core: Show progress during plugin installationMarcus Tillmanns2025-06-241-2/+3
| | | | | | | | | | | Add a bool return value to the postCopyOperation so we can cancel the copy from it. Delete the installation folder if the copy failed or was interrupted by the user. Fixes: QTCREATORBUG-33069 Change-Id: Iee6c77b8f67df8249c1c4571c409bc3c3697af56 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Move FileUtils::makeWritable to FilePathhjk2025-05-211-5/+0
| | | | | | | Easier to discover there. Change-Id: I1ffd33e64d706a21f3c0d523f6410bf31b7652a0 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
* Utils: Remove FileReader classhjk2025-04-231-29/+0
| | | | | | | It's unused now. Change-Id: I9bc62a03a164616bcc3a149cf07e7937adbafd23 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Utils: Merge the two FileSaver::write() overloadshjk2025-04-231-9/+2
| | | | | | | | Some conversions to QByteArray have to be explicit now, but there's no extra copy, as this was implicit before. Change-Id: Idc1b77537410a5a5ec7336cbaccf36346611ea06 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Utils: Split user interaction out of FileSaver::finalize()hjk2025-04-231-10/+5
| | | | | Change-Id: Ib3b968fe6912b659c150481c8cfea7596dbc200b Reviewed-by: David Schulz <david.schulz@qt.io>
* Utils: Return Result<> from one of the FileSaver::finalize() overloadshjk2025-04-231-13/+4
| | | | | | | Change-Id: Iebd2cbbd0d577503b8fc84e95066f4dad6bbe899 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
* Utils: Move Utils::FileReader::fetchQrc out of FileReaderhjk2025-04-171-9/+9
| | | | | | | | | | The FileReader class is about to be removed. Also, centralize the QString::fromUtf8() call, which was effectively present on each caller site. Change-Id: Ia593739ad9ff906b098a5dfc725eb827d10f3848 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* Utils: Return Result<> from FileReader::fetch()hjk2025-04-161-8/+8
| | | | | | | ... instead of keeping an internal error string. Change-Id: Ic529a8bd1ba2a89b3ca3d039e0f98632738960cd Reviewed-by: David Schulz <david.schulz@qt.io>
* Fix warning for ';'Marco Bubke2025-04-151-1/+1
| | | | | | | | The macro already contain a ';'. Removing the argument or [[maybe_unused]] would maybe even a better approach. Change-Id: I31750d10a4f252c667e7c0e5e13bf1085dbe11a2 Reviewed-by: hjk <hjk@qt.io>
* Replace a few make_unexpected with ResultErrorhjk2025-04-151-1/+1
| | | | | Change-Id: I64637b8b43c1932dee59e37b8922c18d27c2deb9 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Replace most expected_str by Utils::Resulthjk2025-04-111-5/+5
| | | | | | | | Keep it in Axivion dto, which is generated. Change-Id: I83a12de6234ac7b0218b369875bdc72d25dbadfb Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Utils: Replace Result class by type alias to std::expected<T, QString>hjk2025-04-111-14/+14
| | | | | | | | | | | | | | ... to be able to conveniently return also non-void cases without being exposed to the syntax of expected. The price for the more general approach is some uglification of the void case: The previous 'Result' is now equivalent to 'Result<>', which needs to be spelled out in function signatures, and some changes to the special cases. Change-Id: Ic5026e237ef2077a0765cdb8287122cae99d699f Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* FileUtils: Use Result inside TempFileSaverhjk2025-03-311-26/+22
| | | | | Change-Id: I2b4f584d5ea8fe73e1310756eb8302a85c93d01a Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Replace more uses of FilePath::toUrlishString()hjk2025-03-131-2/+2
| | | | | | Task-number: QTCREATORBUG-32577 Change-Id: I161cf4e8e5c5120e70d3d51c70be0d9e4f953a79 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
* Utils: Rename FilePath::toString() into toUrlishString()hjk2025-01-101-2/+2
| | | | | | | | | | | | | | | | toString() is almost always the wrong conversion, but unfortunately too easy to find and often even working at least for local setup. This here raises the bar as the non-availability of the "obvious" toString() hopefully helps people to think about the semantics of the needed conversion and choose the right toXXX() function. The chosen new name is intentional ugly to reduce the likelihood that this (still almost always wrong) function is used out of convenience. Change-Id: I57f1618dd95ef2629d7d978688d130275e096c0f Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Remove parent argument from FileUtils dialogshjk2025-01-061-24/+13
| | | | | | | | | Some were using ICore::dialogParent() directly and the 'nullptr' users were using that implicitly, but quite a few actually effectively changed now from some local widget to (implicit) ICore::dialogParent(). Change-Id: Ibb2767b1289221dd26757361235ee88df4a1695e Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Merge one FileReader use in its only userhjk2024-12-161-11/+0
| | | | | Change-Id: Ie9ab42b33c0fe95bb17d82f07ad83a32324e459c Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Simplify FileReader interfacehjk2024-12-131-11/+12
| | | | | | | | | It was either used with QIODevice::Text, or not. Moving the \r\n -> \n replacement to the result accessor make passing the flags unnecessary. Change-Id: I686f992a07734f1805617c245774b357c6d42025 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Add FilePath::isLocal() and use it instead of !needsDevice()hjk2024-12-091-7/+7
| | | | | | | | "needsDevice()" is an odd name, but keep it for now until downstream has caught up. Change-Id: I1fdb65d55e84e31512edb8f0bea8a0a3f7b2879c Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
* Utils: Replace FileUtils class by a FileUtils namespacehjk2024-11-201-62/+65
| | | | | Change-Id: I33be0a11cef008d7cc6ed7472ffadf6c98b50797 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Libs: Make static QRegularExpression instances static constAlessandro Portale2024-11-201-4/+8
| | | | | Change-Id: Ie5a2675651bd83128123cc18601141ba11a13e81 Reviewed-by: hjk <hjk@qt.io>
* Utils: disable atomic save on windows fat file systemDavid Schulz2024-11-201-1/+37
| | | | | | Fixes: QTCREATORBUG-29942 Change-Id: I10e0b541a364b7929bc2fa37fdc4f6e504f6b675 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Merge remote-tracking branch 'origin/15.0'Eike Ziller2024-11-201-1/+1
|\ | | | | | | | | | | | | | | Conflicts: cmake/QtCreatorIDEBranding.cmake qbs/modules/qtc/qtc.qbs Change-Id: I86367f62de8f6ac6529799850deb96428f66009f
| * Utils: Fix copyFileIfNewer's check for identitical file contentshjk2024-11-141-1/+1
| | | | | | | | | | | | | | Amends 31dd9c87f83c8. Change-Id: I1b8abf2395f2bf397b7ab2920cbc4b70ddc53520 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
* | Fix Windows buildAlessandro Portale2024-11-151-1/+1
| | | | | | | | | | Change-Id: Idac06dcb2d12ed959c9a39e663c1fa71a69dbe8e Reviewed-by: hjk <hjk@qt.io>
* | Utils: Make FileUtils::copyIfDifferent return Result instead of boolhjk2024-11-151-10/+11
|/ | | | | | Change-Id: I84191384fcc792030a1c70dea22fd760ae121561 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io> Reviewed-by: Cristian Adam <cristian.adam@qt.io>
* Replace a few expected_str<void> by Utils::Resulthjk2024-10-081-1/+1
| | | | | Change-Id: I160c4dea583958e4cf55ff4de5b9f9c4937ac07f Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
* Utils: Remove remote specific code from FileSaverMarcus Tillmanns2024-09-121-26/+9
| | | | | | | Remote devices support enough functionality now that this is no longer needed. Change-Id: I5c9d3cba6d9e7511b43360f95472cc5c7893676f Reviewed-by: hjk <hjk@qt.io>
* Utils: Fix CopyAskingForOverwriteMarcus Tillmanns2024-09-121-0/+2
| | | | | | | When User selects "Yes to All", only the first dest was deleted. Change-Id: Iecaca8783791687e0172abb5767a19891b5242c8 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
* Fix some deprecation warningsOrgad Shaneh2024-08-281-1/+1
| | | | | | | | | | | | | warning C4996: 'QString::fromUcs4': Use char32_t* overload. warning C4996: 'QString::fromUtf16': Use char16_t* overload. id.cpp(133): warning C4927: illegal conversion; more than one user-defined conversion has been implicitly applied navigationtreeview.cpp(47): warning C4996: 'QAbstractItemView::itemDelegate': Use itemDelegateForIndex instead transientscroll.cpp(428): warning C4996: 'QHoverEvent::pos': Use position() qmldebugconnectionmanager.cpp(194): warning C4996: 'QScopedPointer<QmlDebug::QmlDebugConnection,QScopedPointerDeleter<T>>::take': Use std::unique_ptr instead, and call release(). qmljsdocument.cpp(373): warning C4996: 'QCryptographicHash::addData': Use the QByteArrayView overload instead Change-Id: I4827cc105b0a6af94ff2a5f72edab99997b5ae98 Reviewed-by: hjk <hjk@qt.io>
* Core: Allow users to open output window contents in scratch bufferChristian Kandeler2024-07-191-0/+22
| | | | | | Task-number: QTCREATORBUG-31144 Change-Id: I474e60392281c5e3bd769d64719c3c6a31c57d2f Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Fix FileUtils::copyRecursively with user interactionAlessandro Portale2024-07-081-43/+43
| | | | | | | | | | | | | | | CopyAskingForOverwrite got passed around as value, thus it got copied. The messagebox results were stored into the fields of such copies, and therefore had not the expected values across the recursion. This change wraps the copy helper function into a lambda and the lambda is passed around instead of the object. It may still be a bit much decoupling architecture for a single use-case, but it works now (for me). Fixes: QTCREATORBUG-31174 Change-Id: I5444d18d7bf4ef59ab879e31e5233eadf1c935e4 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
* Utils: Make injected default dialog parent better re-usablehjk2024-05-241-13/+2
| | | | | | | | ... and use it for CheckableMessageBox. This enables using the proper parent e.g. in upcoming changes to ExtensionSystem. Change-Id: Ib0e52cbd3e73dc628955918e3f443ff65cccb189 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Add an environment variable for disabling atomic saveEike Ziller2024-04-241-1/+2
| | | | | | | | | There are situations where e.g. anti virus software leads to saving files failing. Provide a way to disable atomic save for debugging purposes. Task-number: QTCREATORBUG-30728 Change-Id: I1f3df009f89f6c27b2e0c9f91869b2a75f5575d8 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* Utils: Add FilePath constructor for TempFileSaverMarcus Tillmanns2024-02-121-0/+28
| | | | | | Change-Id: I15286be055bd69544e4283740bd0c3411573475c Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
* Utils: Promote a local conversion function to FilePath::fromUrl()hjk2024-01-261-10/+3
| | | | | Change-Id: I748cceb50084a29b971f31a8bd2ad7159738d7fd Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
* ScreenRecorder: Add additional search pathsMarcus Tillmanns2023-11-011-0/+15
| | | | | | | | | Adds a function FileUtils::usefullExtraSearchPaths() that returns OS specific paths that often are not in PATH by default, but contain useful apps we want to find. Change-Id: Ideb7c45b241c69c9f2db8f75726bb63249000a5f Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
* Utils: Be a bit more verbose in debug outputhjk2023-10-181-1/+1
| | | | | | Change-Id: I0fd7bc92784efa184bac1cdbd5ae4c2d0158fb28 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* FilePath: Use isSameDeviceMarcus Tillmanns2023-08-081-2/+1
| | | | | | | | | | | Some places compared the scheme and host of a filepath to decide whether its the same device. This is incorrect and leads to false negatives. isSameDevice is the correct way to decide whether two paths are from the same device. Fixes: QTCREATORBUG-29474 Change-Id: Iced8f434dadb931f6595f47f95647b341c48d3aa Reviewed-by: hjk <hjk@qt.io>
* Fix some more *::count() deprecation warningshjk2023-06-071-1/+1
| | | | | Change-Id: Ib7d1552a6f7b167e15beb7ca1ef26c7d57e090e9 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Fix macOS permissions parsingMarcus Tillmanns2023-05-311-3/+9
| | | | | | Change-Id: I5fdde04c197b5db323fc8630c4ee4b2c197d947a Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Doc: Add "\inmodule QtCreator" to \class and \namespace docsLeena Miettinen2023-05-221-1/+3
| | | | | | | To get rid of QDoc warnings. Change-Id: Idd39b7ae4327798c376f424c94d6617bcaee2258 Reviewed-by: hjk <hjk@qt.io>
* Merge remote-tracking branch 'origin/10.0'Eike Ziller2023-04-261-0/+4
|\ | | | | | | Change-Id: I02df4ad5e4a074f572cd6dd33551864e7c82f51c
| * Utils: Fix line ending conversion in FileReaderMarcus Tillmanns2023-04-251-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | FilePath::fileContents always uses "binary" mode when reading files. FileReader::fetch previously used QFile with QIODevice::Text mode to read (local) files, which converts \r\n to \n. This patch re-introduces the conversion. Fixes: QTCREATORBUG-29040 Change-Id: I0a16b056bea456512e6526497b725c73b0a1bd11 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>