summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qdir.h
Commit message (Collapse)AuthorAgeFilesLines
* Add QDirListing, an STL-style iterator for directory entriesAhmad Samir2024-02-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | This class offers a forward-only const_iterator, that matches the system low-level functions' logic (e.g. readdir()/dirstream logic). This iterator is a std::input_iterator_tag. QDirIterator uses Java-style iterators that have a couple of issues: - They don't fit the logic of the underlying native system functions (readdir()/__dirstream and co.), there is no way to know if there is a next entry except by advancing the iterator (calling readdir()) first - As a consequence of the above, two QFileInfo objects, current and next, had to be used to fit that paradigm; and the code always iterated/stat'ed an extra entry past the one we want, e.g. when filtering The next step is porting QAbstractFileEngineIterator and its subclasses to be like QFileSystemIterator, i.e. replace hasNext()/next() with a `bool advance()` virtual method. This is easier to reason about than the Java-style iterators, and is more in-line with the new class. Discussed-on: https://lists.qt-project.org/pipermail/development/2023-December/044745.html Change-Id: I8e696cefdca18d8c78f803efdb83a73dd43eb720 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDir: Use new comparison helper macrosRym Bouabid2024-02-131-0/+5
| | | | | | | | | | | | QDir had operator==() and operator!=() defined as public member functions, so use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of these methods and replace them with a hidden friend. Use QTestPrivate::testEqualityOperators() helper function in unit-tests. Task-number: QTBUG-120303 Change-Id: I86c2ba18b8b114efd9f62fc2fd628bc9065b04b2 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Replace usages of Q_CLANG_QDOC with Q_QDOCLuca Di Sera2022-10-211-4/+4
| | | | | | | | | | | | | | | | | | | | | | | To allow the user to customize the C++ code that QDoc sees, so as to be able to work-around some limitations on QDoc itself, QDoc defines two symbols: Q_QDOC and Q_CLANG_QDOC, both of which are "true" during an entire execution of QDoc. At a certain point in time, QDoc allowed the user the choice between a custom C++ parser and a Clang based one. The Q_QDOC symbol would always be defined while the Q_CLANG_QDOC symbol would be defined only when the Clang based parser was chosen. In more recent times, QDoc always uses a Clang based parser, such that both Q_CLANG_QDOC and Q_QDOC are always defined, making them equivalent. To avoid using different symbols, and the possible confusion and fragmentation that derives from it, all usages of Q_CLANG_QDOC are now replaced by the equivalent usages of Q_QDOC. Change-Id: I5810abb9ad1016a4c5bbea99acd03381b8514b3f Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Port QDir to qsizetype [3/3]: APIMarc Mutz2022-09-071-0/+6
| | | | | | | | | | | | | | | | [ChangeLog][QtCore][QDir] The count() function now returns, and the indexing operator now takes, qsizetype (was: uint and int, respectively). [ChangeLog][Potentially Source-Incompatible Changes][QDir] The count() function now returns qsizetype (was: uint). Task-number: QTBUG-103525 Change-Id: Ib84af36f6a95d9a0d1090a2d6fb973a4e363550c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCoreGlobalData: removeMarc Mutz2022-08-211-0/+2
| | | | | | | | | | | | | | | Inline the data members into the only remaining user (qdir.cpp) and remove the class. As a drive-by, fix the non-idiomatic use of QT_BUILD_CORE_LIB to mean !QT_BOOTSTRAPPED and apply the guard consistently to the declaration, too. Pick-to: 6.4 6.3 6.2 Fixes: QTBUG-105747 Change-Id: If2c780dd96e2a2e331cabdc42fd920874e7737b0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QtCore: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-04-111-4/+4
| | | | | | | | Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. Change-Id: Ibe32a11699f67df2aa80505ba2944f33e5e823e0 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QtCore: replace qSwap with std::swap/member-swap where possibleMarc Mutz2022-01-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qSwap() is a monster that looks for ADL overloads of swap() and also detects the noexcept of the wrapped swap() function, so it should only be used when the argument type is unknown. In the vast majority of cases, the type is known to be efficiently std::swap()able or to have a member-swap. Call either of these. For the common case of pointer types, circumvent the expensive trait checks on std::swap() by providing a hand-rolled qt_ptr_swap() template, the advantage being that it can be unconditionally noexcept, removing all type traits instantiations. Don't document it, otherwise we'd be unable to pick it to 6.2. Effects on Clang -ftime-trace of a PCH'ed libQt6Gui.so build: before: **** Template sets that took longest to instantiate: [...] 27766 ms: qSwap<$> (9073 times, avg 3 ms) [...] 2806 ms: std::swap<$> (1229 times, avg 2 ms) (30572ms) after: **** Template sets that took longest to instantiate: [...] 5047 ms: qSwap<$> (641 times, avg 7 ms) [...] 3371 ms: std::swap<$> (1376 times, avg 2 ms) [qt_ptr_swap<$> does not appear in the top 400, so < 905ms] (< 9323ms) As a drive-by, remove superfluous inline keywords and template ornaments. Task-number: QTBUG-97601 Pick-to: 6.3 6.2 Change-Id: I88f9b4e3cbece268c4a1238b6d50e5712a1bab5a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QDir: Add support for setting directory permissions to mkdir()Ievgenii Meshcheriakov2021-11-261-0/+1
| | | | | | | | | | | | | | This patch adds an overload of the QDir::mkdir() method that accepts permissions. This allows setting of the directory permissions at the time of its creation. [ChangeLog][QtCore][QDir] Added QDir::mdkir() overload that accepts permissions argument. Task-number: QTBUG-79750 Change-Id: Ic9db723b94ff0d2da6e0b819ac2e5d1f9a4e2049 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Whitespace cleanup in corelib/iov6.0.0-beta2Allan Sandfeld Jensen2020-10-201-7/+3
| | | | | | | | | Selective application of clang-format to follow our coding style where it is significantly off. Change-Id: I0ff4ed146fe53922691d5473d0c236f31d478a04 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Centralize the implementation of move assignment operatorsGiuseppe D'Angelo2020-10-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At the moment we have two main strategies for dealing with move assignment in Qt: 1) move-and-swap, used by "containers" (in the broad sense): containers, but also smart pointers and similar classes that can hold user-defined types; 2) pure swap, used by containers that hold only memory (e.g. QString, QByteArray, ...) as well as most implicitly shared datatypes. Given the fact that a move assignment operator's code is just boilerplate (whether it's move-and-swap or pure swap), provide two _strictly internal_ macros to help write them, and apply the macros across corelib and gui, porting away from the hand-rolled implementations. The rule of thumb when porting to the new macros is: * Try to stick to the existing code behavior, unless broken * if changing, then follow this checklist: * if the class does not have a move constructor => pure swap (but consider ADDING a move constructor, if possible!) * if the class does have a move constructor, try to follow the criteria above, namely: * if the class holds only memory, pure swap; * if the class may hold anything else but memory (file handles, etc.), then move and swap. Noteworthy details: * some operators planned to be removed in Qt 6 were not ported; * as drive-by, some move constructors were simplified to be using qExchange(); others were outright broken and got fixed; * some contained some more interesting code and were not touched. Change-Id: Idaab3489247dcbabb6df3fa1e5286b69e1d372e9 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Fix some qdoc warnings: std::filesystem::path gettersVolker Hilsheimer2020-09-221-1/+1
| | | | | | | Those APIs need to be declared for qdoc runs, even if cxx17_filesystem is not. Change-Id: Iaa437aa424f35d0414b6b79328bcafb49af872b3 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Replace Qt CONSTEXPR defines with constexprAllan Sandfeld Jensen2020-08-141-1/+1
| | | | | | | | Both normal and relaxed constexpr are required by our new minimum of C++17. Change-Id: Ic028b88a2e7a6cb7d5925f3133b9d54859a81744 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Purge deprecated API from QDirEdward Welbourne2020-08-071-10/+1
| | | | | | | | | Assignment from QString and addResourceSearchPath(), both deprecated since 5.13. Change-Id: I25f08ffadc7b9dfd7895a9199255ca5f1948bd47 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Inline QDir::separator(), as requested by a ### Qt6 commentEdward Welbourne2020-07-271-1/+8
| | | | | | | Task-number: QTBUG-85700 Change-Id: Icd44e428b607703defb9be1c149db6a564e6b4f0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Q{File,FileInfo,Dir}: add std::filesystem::path overloadsMårten Nordheim2020-03-241-1/+43
| | | | | | | | | | | | | | | | | | | | Add some overloads where (I thought) it makes sense for QDir and QFile to accept std::filesystem::path objects. Currently my thinking is to not add overloads for static functions where std::filesystem can already do the same job, e.g. create directory or file. Template and enable_if is needed due to both QString and std::filesystem::path being able to be constructed from string literals. The common shared code is currently in QFile because QDir had an implicit include of QFile, made explicit in this patch, and QFileInfo has an include to QFile as well. The QT_HAS_STD_FILESYSTEM macro is visible in user-code which I currently take advantage of in the tests, and users could too. Change-Id: I8d05d3c34c6c17e20972a6a2053862b8891d6c3c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove handling of missing Q_COMPILER_RVALUE_REFSAllan Sandfeld Jensen2019-04-081-2/+0
| | | | | Change-Id: I7bc6c455fbae4cdad584c76773299a6d8cd40c82 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace Q_DECL_NOEXCEPT with noexcept in corelibAllan Sandfeld Jensen2019-04-031-3/+3
| | | | | | | In preparation of Qt6 move away from pre-C++11 macros. Change-Id: I44126693c20c18eca5620caab4f7e746218e0ce3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtCore: mark obsolete functions as deprecatedChristian Ehrlicher2019-01-231-0/+6
| | | | | | | | | | | | | | | Mark the following obsolete functions as deprecated so they can be removed with Qt6: - QDataStream::unsetDevice() - QDir &QDir::operator=(const QString &path) - QDir::addResourceSearchPath() - QResource::addSearchPath() - QResource::searchPaths() - QSettings::setSystemIniPath() - QSettings::setUserIniPath() Change-Id: I5edfb2b4ce1ad843fa5fcd5b4c475ab9352b05f7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Migrate QDir to use QRegularExpressionSamuel Gaist2018-08-191-1/+1
| | | | | | | | | | | | | | | The match method still uses QRegExp. This patch updates the code to use QRegularExpression and translates the wildcard patterns to a suitable form for QRegularExpression. [ChangeLog][Core][QDir] QDir now uses QRegularExpression internally for wildcard matching. Note that QRegularExpression might not give the exact same result as QRegExp as its implementation follows strictly the glob patterns definition for wildcard expressions. Nevertheless, the tests for QDir return the same results as before. Change-Id: I095959443ac7362f7534e35454eff038061fca82 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Introduce QDir::isEmpty()Elvis Angelaccio2017-01-081-0/+2
| | | | | | | | | | | | A directory is empty when it doesn't contain files or folders. We can exploit QDirIterator::hasNext() to check whether this is the case. This is efficient since it doesn't list the whole folder (in the non-empty case). Test cases are added for both the empty and non-empty cases. Change-Id: I0f7e26782c0f97f9c16f928dab6cae37927875d8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* QtCore: make all Q_DECLARE_SHARED types nothrow move-assignableMarc Mutz2015-06-301-3/+2
| | | | | | | Excepting QDebug, which doesn't have value semantics. Change-Id: I43757ef7bba4c1f5b6de9144f12b38ce840cd9f9 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Introduce QDir::listSeparator()Sérgio Martins2015-05-271-1/+10
| | | | | | | | | | | | | Qt should help abstract such platform differences. This ifdef is proliferating in user code (seen a few times in KDE) and even in Qt code (qstandardpaths.cpp). [ChangeLog][QtCore][QDir] Added listSeparator(). Change-Id: Icad082a51c8efd5d63f7af9bbaedbe4bc15b8937 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Remove QT_{BEGIN,END}_HEADER macro usageSergio Ahumada2013-01-291-4/+0
| | | | | | | | | | | The macro was made empty in ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: Id2bb2e2cabde059305d4af5f12593344ba30f001 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* QtCore: mark some classes as sharedMarc Mutz2012-07-101-0/+1
| | | | | Change-Id: I811d3eebd87c230883cc579c20f9fa4e14ff9521 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtCore: add member-swap to shared classesMarc Mutz2012-07-031-0/+3
| | | | | | | | | | Implemented as in other shared classes (e.g. QPen). Special case: QUrlQuery: document existing swap(). Change-Id: I4b36cc9577fbf2232d4b2a2d8822d26e41e22cad Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDirIterator: don't inherit from QDirMarc Mutz2012-03-231-0/+2
| | | | | | | | | | | | Remove the inheritance hack used in QDirIterator to gain access to QDir's d-pointer by simply making QDirIterator a friend of QDir. This allows to turn QDir into a final class. Change-Id: I97efef8714bb194d62b9fe5192ce240a90f2bf97 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDir::NoDotAndDotDot is now QDir::NoDot|QDir::NoDotDot.Jonas M. Gastal2012-01-311-1/+1
| | | | | | Change-Id: I8ef7782258c2ec02ad2ec2a5d5cab90f53c62aa3 Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Remove use of QT_MODULE from libraryGunnar Sletta2012-01-251-1/+0
| | | | | | | | | | These defines were there to aid in the commercial licensing scheme we used long ago, and are no longer needed. Keep a QT_MODULE(x) define so other modules continue compiling. Change-Id: I8fd76cd5270df8f14aee746b6cf32ebf7c23fec7 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Remove QDir::convertSeparators()Lars Knoll2012-01-191-3/+0
| | | | | | | | | This method has been deprecated since Qt 4.2. QDir::toNativeSeparators() replaces it since then. Change-Id: I49e6e1bfd50f26aa30134e599ee82067709549a7 Reviewed-by: Robin Burchell <robin+qt@viroteck.net> Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Implement QDir::removeRecursivelyDavid Faure2011-12-021-0/+2
| | | | | | Task-number: QTBUG-4592 Change-Id: I363e2c24d1c0ada975b8b927d7c6e776b8aae579 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* Add Q_DECLARE_PRIVATE equivalent for QDir, to be able to subclass itDavid Faure2011-11-081-4/+15
| | | | | | | | Apply the same solution to QFileInfo (no public detach(), but a non-inline d_func instead). Change-Id: I31c4c759f44a0649b97f7884b078b174c9c00f22 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* remove QT3_SUPPORT in corelib/ioLars Knoll2011-06-291-45/+0
| | | | | | | Change-Id: Ia9ad0bebacc538a7392afb0fdcca40e8a2bb687b Reviewed-on: http://codereview.qt.nokia.com/865 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Liang Qi <liang.qi@nokia.com>
* Update licenseheader text in source files for qtbase Qt moduleJyri Tahtela2011-05-241-17/+17
| | | | | | | Updated version of LGPL and FDL licenseheaders. Apply release phase licenseheaders for all source files. Reviewed-by: Trust Me
* Initial import from the monolithic Qt.Qt by Nokia2011-04-271-0/+271
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12