summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfilesystemiterator_unix.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QFileSystemIterator/Darwin: enforce NFC encoding in QStringThiago Macieira2024-02-221-1/+9
| | | | | | | | | | | | | Amends 83f7125ac866ed5a2aaace56ffc866f21f9730b4. We replaced QFile::decodeName() with QStringDecoder so we'd know whether the decoding from UTF-8 had failed, but forgot about Darwin's enforced normalization. Fixes: QTBUG-122624 Change-Id: I01ec3c774d9943adb903fffd17b5edc54c34c067 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Robert Griebl <robert.griebl@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QFileSystemIterator/Unix: use QStringDecoderAhmad Samir2024-02-091-16/+18
| | | | | | | | | | | | | | | | | | | | The end result is a QFileInfo constructed from the QFileSystemEntry; QFileSystemEntry's API will at some point convert the NativePath (QBA on Unix) to a QString, e.g. when it calls findLastSeparator(). So instead of converting the parent dir path from Utf8 to Utf16 multiple times, store the dir path as a QString once in the constructor. Use QStringDecoder to convert the dirent->d_name to Utf16 and check the decoder's hasError(); which as Thiago pointed out, is more efficient than using isValidUtf8(), throwing away the results, then converting to unicode anyway later on in QDirIteratorPrivate::advance(). (Ironically) `QFileSystemEntry::NativePath nativePath` is still used on Windows. Change-Id: Icd2b130103640b502862d210d64926b99c499a01 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFileSystemIterator: simplify the constructorAhmad Samir2024-02-031-4/+1
| | | | | | | | Neither implementation (Unix and Windows) uses the QStringList or the QDir::Filters args. Change-Id: I6a552e41eb37e4b76246e35d43ac4d34a4ae9d12 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFileSystemIterator: set errno to 0 before calling readdir()Ahmad Samir2024-02-031-0/+12
| | | | | | | | | | | So that errno can be used to distinguish between "reached end of dir stream" state and an error. Set errno to something more useful (EILSEQ) when we fail to decode an entry's name, requested by Thiago in code review. Change-Id: I8091144d25e5e5aa875cf40eaf6ee13c9e409ee7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFileSystemIterator: manage dirstream with unique_ptrAhmad Samir2024-02-031-10/+4
| | | | | | | | | | | Less manual resource clean-ups. Drive-by changes, initialize members in-class. Also remove an unused include. Change-Id: I03cd12e1c6c12338d09daba916cd34cb36f04260 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* 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>
* Convert a couple of APIs to use viewsLars Knoll2020-10-061-1/+1
| | | | | | | | | | | Try to get rid of APIs that use raw 'const {char, QChar} *, length' pairs. Instead, use QByteArrayView or QStringView. As QStringConverter is a new class, simply change the API to what we'd like to have. Also adjust hidden API in QStringBuilder and friends. Change-Id: I897d47f63a7b965f5574a1e51da64147f9e981f6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add ; to Q_UNUSEDLars Schmertmann2020-07-071-3/+3
| | | | | | | | This is required to remove the ; from the macro with Qt 6. Task-number: QTBUG-82978 Change-Id: I3f0b6717956ca8fa486bed9817b89dfa19f5e0e1 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Remove QTextCodec dependency from qfilesystemiteratorLars Knoll2020-05-141-37/+2
| | | | | | | | | | | | | | | Assume Unix systems are utf-8 based nowadays. glib has been assuming this for quite some time already, and all Linux and BSD systems shipped in the last 10 years assume utf-8 for 8-bit strings. Utf-8 is also the encoding used by macOS and QNX since a very long time. File systems where file names are not encoded in utf-8 can usually be translated transparently to utf8 by specifying appropriate mount options. Change-Id: I1970496db24e59dee8efb79ba025355a3ce87387 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move the UTF conversion methods to qstringconverterLars Knoll2020-05-141-1/+1
| | | | | | | | | | | | | | Separate them from the qutfcodec, so that the codec can later on be moved out of Qt Core. Fix the QUtf methods to take qsizetype instead of int for length arguments. This also makes it possible to not build QTextCodec into the bootstrap lib anymore. Change-Id: I0b4f83139d61b19c651520a2f3a5012aa7e85cb8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/dev' into wip/cmakeAlexandru Croitor2019-10-141-1/+5
|\ | | | | | | Change-Id: I4a78428a8ea273b6960792e3b8043f816fa37fcf
| * Build fix for -developer-build with certain features disabledGuy Poizat2019-10-041-0/+2
| | | | | | | | | | | | | | | | | | When building with -developer-build the unused-parameter warning is a build breaker error, but some combinations of -no-features was still making it happen. Change-Id: Ib6354e6a599b8d64fd593fb94e9cfa32db63c77d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
| * Merge remote-tracking branch 'origin/5.13' into 5.14Liang Qi2019-09-301-1/+3
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qrandom.cpp src/corelib/io/qfileinfo.cpp src/corelib/kernel/qeventdispatcher_win.cpp src/corelib/kernel/qeventdispatcher_win_p.h src/gui/text/qfontdatabase.cpp src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm src/plugins/platforms/windows/qwindowsglcontext.cpp src/testlib/qtestcase.cpp Done-With: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Done-With: Edward Welbourne <edward.welbourne@qt.io> Change-Id: I4893212471aa24be804c989a581810e2f714545c
| | * Filesystem: avoid crashes on exit in case the locale codec is nullThiago Macieira2019-09-241-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On exit, QLocale::codecForLocale() can return null as the codec may have already been destroyed. In that case, pretend that Latin1 was the locale, so any file name is acceptable. This matches QString: QTextCodec *codec = QTextCodec::codecForLocale(); if (codec) return codec->toUnicode(str, size); #endif // textcodec return fromLatin1(str, size); Note that if we're wrong and the locale was *not* Latin1, files that you had a name to may not be encoded or decoded the same way. Fixes: QTBUG-78446 Change-Id: Iece6e011237e4ab284ecfffd15c54077728a17ca Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | | Fix qmake build in developer buildsLeander Beernaert2019-08-161-0/+2
|/ / | | | | | | | | | | | | | | When building with developer builds, all targets are built with warnings as errors. In CMake this also applies to the qmake build. Change-Id: Ie62681d6c4756c106f5931a2a7d452a18dfa45f1 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* | Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-07-171-3/+44
|\| | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qlogging.cpp src/gui/painting/qtextureglyphcache_p.h src/gui/text/qfontengine.cpp src/widgets/widgets/qlineedit.cpp Change-Id: Ic8798538df466b7141caa8bbf1fb7605eb56be37
| * QDirIterator: don't require NFD normalization on Darwin for validityThiago Macieira2019-07-111-3/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | HFS+ filesystems do enforce NFD normalization, so the test worked for those filesystems. But on APFS, the filesystem is normalization- insensitive but preserves it, so our transformation caused valid files to be rejected. This commit also optimizes the solution for all systems too. Instead of converting from 8-bit to UTF-16 then back to 8-bit (allocating memory in both steps), we only convert to UTF-16. And if we detect the locale is UTF-8, then we use the further optimized QUtf8::isValidUtf8 function that doesn't allocate any memory at all (ditto for US-ASCII, the case of someone running with LANG=C). Fixes: QTBUG-76522 Change-Id: Ief874765cd7b43798de3fffd15aa0d81620ad317 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Move away from using 0 as a pointer constantAllan Sandfeld Jensen2019-06-071-3/+3
|/ | | | | | | | | Cleans up most of corelib to use nullptr or default enums where appropriate. Change-Id: Ifcaac14ecdaaee730f87f10941db3ce407d71ef9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDirIterator: Skip inconvertible file names on UnixAlexander Volkov2017-11-141-5/+12
| | | | | | | | | | | | | | | In the case when user's local encoding is UTF-8, QDirIterator may list entries which names can't be correctly converted from UTF-8 to UTF-16, e.g. for "\xC0\xB0" file name QDirIterator::fileName() returns "\uFFFD\uFFFD" (FFFD is a code of Replacement Character). The problem is that you can't do anything with such directory entries because there is no way to get the original entry names. List only those names that can be converted to QString and then back to the local encoding without corruption. Change-Id: Ib6a71dea8ce9601876040c07276c325fd997e767 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-11-041-38/+0
|\ | | | | | | | | | | | | | | Conflicts: src/corelib/json/qjsonparser.cpp src/gui/opengl/qopengl.cpp Change-Id: Ib4d3208398399691839e6c6eaeb9006f99e3a62b
| * Stop using readdir_r: glibc deprecated it and it's not a good ideaThiago Macieira2016-11-031-38/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | POSIX does not require that readdir() be reentrant even for operations on different dirent objects, but all implementations (according to the glibc documentation) already do that. Moreover, it's not a good idea to use readdir_r since the buffer space is limited by the caller, so certain file names may be too long (ENAMETOOLONG) -- we had a workaround for QNX, but for no other OS. According to the glibc documentation, it is expected that POSIX will mark readdir_r obsolete and instead require some form of reentrancy for readdir. This commit makes everyone use readdir instead. The macros in qplatformdefs.h are left behind in case someone else is using them. With glibc 2.24, we started getting: qplatformdefs.h:150:35: warning: ‘int readdir_r(DIR*, dirent*, dirent**)’ is deprecated [-Wdeprecated-declarations] qfilesystemiterator_unix.cpp:112:17: note: in expansion of macro ‘QT_READDIR_R’ Task-number: QTBUG-56088 Change-Id: I33dc971f005a4848bb8ffffd14749b4082f62e69 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: James McDonnell <jmcdonnell@blackberry.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>
* 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>
* QNX: Fix QDir::entryInfoList()Bernd Weimer2014-04-141-7/+8
| | | | | | | | | | | | If D_FLAG_FILTER is set, duplicate name entries are filtered out, so this flag has to be set along with D_FLAG_STAT in the call to dircntl. Also releaved dependencies between defines__EXT_QNX__READDIR_R, __EXT_QNX__READDIR64_R and _POSIX_THREAD_SAFE_FUNCTIONS Task-number: QTBUG-38189 Change-Id: I4e620cb9967e3d1baf6f2109a7c83703702f805b Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
* QNX: Make use of _readdir64_rBernd Weimer2013-11-251-2/+2
| | | | | | | | | | | Latest QNX versions support _readdir64_r. It will be used by QFileSystemIterator now, when available to support large file systems. Change-Id: I40135f405ad72e1ba85c6a4cd282144dd8171bc6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com> Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.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>
* QNX: Use extra information in dirent to avoid stat() callsThomas McGuire2012-10-191-1/+17
| | | | | | | | | | | | This improves iterating over /usr/bin with QDirIterator by more than half, from 36 to 13 milliseconds. Change-Id: Ib3a9271c3a6f81c1ea3c21d012c875c7e9bad2ad Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.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>
* 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>
* 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>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@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/+117
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