summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
Commit message (Collapse)AuthorAgeFilesLines
* QDirIterator: add nextFileInfo()Marc Mutz21 hours5-27/+40
| | | | | | | | | | | | | | | | | | | | | | | Before this change, next() was the only way to advance the iterator, whether the caller was ultimately interested in just the filePath() (good) or not (bad luck, had to call .fileInfo()). Add a new function, nextFileInfo(), with returns fileInfo() instead. Incidentally, the returned object has already been constructed as part of advance()ing the iterator, so the new function is faster than next() even if the result is ignored, because we're not calculating a QString result the caller may not be interested in. Use the new function around the code. Fix a couple of cases of next(); fileInfo().filePath() (just use next()'s return value) as a drive-by. [ChangeLog][QtCore][QDirIterator] Added nextFileInfo(), which is like next(), but returns fileInfo() instead of filePath(). Change-Id: I601220575961169b44139fc55b9eae6c3197afb4 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* io: Remove version checks for versions below Win 10Mårten Nordheim23 hours3-77/+37
| | | | | | | It's not supported. Change-Id: Ia17fc7e1d5ae785eca0a6ba530f9b9bc960605d4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrlQuery/Doc: update the information about encoded vs decodedThiago Macieira39 hours1-1/+28
| | | | | | | | | | | This class was not subject to the QUrl API update that took place between 5.0 and 5.1 that changed the QUrl string defaults and added QUrl::ParsingMode. It always parses as TolerantMode. Fixes: QTBUG-95254 Change-Id: I37d93a60a0d649688bddfffd169348d874eacc92 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix typo in function nameIevgenii Meshcheriakov3 days1-2/+2
| | | | | | | | Fix typo: containsProhibitedOuptut -> containsProhibitedOutput. Pick-to: 6.2 Change-Id: I4eb8be4c7ceb2e96ac129ef7c64215558f7b308e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QFileSelector: Preserve path to root directoryFabian Kosmale8 days1-1/+4
| | | | | | | | | | | | | | | | While QFileSelector is documented to work on files, select accepts arbitrary URLs. Moreover, the QML engine can end up intercepting arbitrary (user provided) URLs, including to directories. Prior to this change, passing "file:///" or "/" to the function would break: We would temporarily get a "//" path, which is invalid, and thus we would return an invalid in the end. Prevent this by only appending a slash to the path when it doesn't have one. Fixes: QTBUG-85410 Pick-to: 6.2 Change-Id: I1d2807a9d225df611c3a5e871e3c1d90a6a25953 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Hold QRingBuffer and QNonContiguousByteDevice in shared_ptrMarc Mutz2021-07-142-22/+22
| | | | | | | | | | | | ... instead of QSharedPointer. QSharedPointer performs twice as many atomic operations per pointer copy as std::shared_ptr, and this is private API, we're not bound by BC constraints, so we can port to the more efficient version. Change-Id: I9572a8321aae381e5dbe4a51119f2c9494a8fbc7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDuplicateTracker: accept the number of elements to reserve as a ctor argumentMarc Mutz2021-07-141-2/+1
| | | | | | | | | | | | This prevents us from first reserve()ing Prealloc elements, and then possibly reserve()ing a larger number, which leaves the first bucket list's memory unused. Consequently, deprecate reserve(). Change-Id: Ifc0a5a021097f4589557e7b5e45d9d0892797ade Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* macOS: Don't mangle QByteArray settings with @ prefix by decoding as UTF-8Tor Arne Vestbø2021-07-131-1/+9
| | | | | | | | | | | | | | | | | | QSettings encodes QVariants as @Type(data) strings. If that data contains a null-byte, we write the string as UTF-8 encoded CFData. When reading it back we look for a @ prefix, and then pass it as UTF-8 through stringToVariant. The problem arises then the user writes raw QByteArrays with a @ prefix. We can detect this situation by checking the result of stringToVariant, and if it's just a simple conversion of the string into a QVariant, we know that stringToVariant hit its fallback path due to not finding any embedded variants. If that's the case, we return the raw bytes as a QByteArray. Pick-to: 6.2 6.1 5.15 5.12 Change-Id: I4ac5c35d0a6890ebea983b9aca0a3a36b0143de2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QNonContiguousByteDevice: ++explicitMarc Mutz2021-07-101-5/+5
| | | | | Change-Id: I5d40a12704789eff10db9b1fb34f4e375651f1f0 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QLocalSocket/Win: reimplement skipData() functionAlex Trotsenko2021-07-082-0/+20
| | | | | | | | The base implementation discards the data by reading into a dummy buffer, which is slower than necessary. Change-Id: Iabf0c4a25746af6cac5b61d7bda66d89501c808c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QLocalSocket: reimplement readLineData() functionAlex Trotsenko2021-07-062-0/+25
| | | | | | | | The base implementation reads data using repeated calls to getChar(), which is quite slow. Change-Id: Ie46624df63791b2cdd3c8a28fe3327427d942505 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Clarify readLine() behavior on sequential devicesAlex Trotsenko2021-07-061-1/+6
| | | | | | | | | | QIODevice::readLine() can also return partial lines, which was not properly documented. Add an autotest for QLocalSocket to illustrate and test this behavior. Pick-to: 6.2 Change-Id: Ia2c1c438cc68d2672d34881e11fdf7837232f3b4 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QWinSettings: port readKey() helper to std::optionalMarc Mutz2021-06-301-28/+15
| | | | | | | | | Less boilerplate code and no more impedance mismatch with recently-ported QSettingsPrivate::get(). Change-Id: I5e113a44a48274aecb20fc9cb5d8db02c6cd0a35 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Port QSettingsPrivate::get() to std::optionalMarc Mutz2021-06-305-31/+25
| | | | | | | | ... instead of a bool return and a QVariant out parameter. Change-Id: I9d937668ede668075d1de5bb57f61e4c260aaddc Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Extend documentation for QFile:copy()Paul Wicking2021-06-231-10/+4
| | | | | | | | | | | | - Add information about symlinks and file metadata. - Reflow text. - Extract text common to both overloads to a .qdocinc file for consistency and to avoid duplication. Pick-to: 6.2 6.1 5.15 Fixes: QTBUG-94706 Change-Id: I3c730fd63f4018a1a573bb56751fedd2270a3247 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QF*Engine: port a couple of QFlags->int implicit conversions to toInt()Giuseppe D'Angelo2021-06-232-4/+4
| | | | | Change-Id: Iafc3527941a0b56a680322e3bc05b4046e560e89 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QWindowsPipeReader::read(): do not switch the mutex twiceAlex Trotsenko2021-06-222-5/+10
| | | | | | | | We can get better performance if we omit unlocking the mutex before relocking it in startAsyncRead(). Change-Id: Ia012a71b95876d4f90c1dc4b7db5d7b267fca7a6 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QWindowsPipeReader::read(): remove redundant checksAlex Trotsenko2021-06-211-5/+1
| | | | | | | | | An initial EOF check is not required here because the code below correctly handles this case. Also, the condition '!pipeBroken' means that the pipe reader is in the 'Running' state. Change-Id: I608d932c4e38f8224d9e655272e61295e55414e0 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcess/Win: cleanup startProcess()Alex Trotsenko2021-06-191-17/+2
| | | | | | | | | Both the call to setProcessState(QProcess::NotRunning) and deleting the PROCESS_INFORMATION structure are redundant here. All this work was done by the previously executed cleanup() call. Change-Id: Iaf89f5edd2b661008a479d154e68974621b1b1eb Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QLocalSocket/Win: simplify flush()Alex Trotsenko2021-06-192-47/+0
| | | | | | | | | | Replacing a call to waitForWrite(0) with checkForWrite() changes nothing in logic, but saves one system call. As a result, unused functions in the QWindowsPipeWriter class have been removed. Change-Id: I34ec6310d9659f59a720056b9be54e31f2193116 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QProcess/Win: avoid double buffering on writeAlex Trotsenko2021-06-186-61/+52
| | | | | | | | | | | | | As QWindowsPipeWriter now maintains a chunk queue, there is no need to use the internal QIODevice buffer and wait for the previous operation to complete. This also allows us to get rid of the stdinWriteTrigger timer; however, as a trade-off, QWindowsPipeWriter now needs to accept data even before a handle is assigned. Change-Id: I17fe0e36a6165fe05100bfab3fe01fc0d880d617 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Allow destruction of QWindowsPipeReader in its signalAlex Trotsenko2021-06-182-19/+18
| | | | | | | | As a result, we can refrain from using the deleteLater() technique in QProcess and avoid long-lived soft leaks in blocking applications. Change-Id: I89e02b02551a668b995ad3d12d3ce9575b2dd9dd Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QWinSettings: use QScopeGuard to RegCloseKey()Marc Mutz2021-06-171-7/+5
| | | | | | | | | RAII rulez. Change-Id: I32bc070ae3074f782a1695bcf2079de0fc19597b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QFileInfo: remove a couple of QFlags->int implicit conversionsGiuseppe D'Angelo2021-06-171-2/+2
| | | | | Change-Id: Iabfca134709852694967d605c6a93f34a9777d8a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QLoggingSettingsParser: port setContent() to QStringViewMarc Mutz2021-06-162-4/+4
| | | | | | | | | | | Amends 16f927a4f1ffeff399351b625d73ac3cd7bccd51. At the time the original change was written, QStringTokenizer had not been integrated, yet. Change-Id: I83c31d816199bc48c4baea855d13cbf9eda9aaa2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QSettings: hide the return type of actualKey() and normalizedKey()Marc Mutz2021-06-151-7/+4
| | | | | | | | It may change in the future. Change-Id: If65bf690b12d4e6474557d7a48567941b18413bf Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDebug: add missing docs for new QVLA streaming operatorMarc Mutz2021-06-151-0/+9
| | | | | Change-Id: I02af3b0e5615c8281b204fad0e6454bf40aca475 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QDebug: add support for QVarLengthArrayMarc Mutz2021-06-131-0/+7
| | | | | | | | | | | | | | Remove a conflicting definition of the same operator from qrhi.cpp. Who knows how many ODR violations this hidden gem may have caused... [ChangeLog][QtCore][QDebug] Can now stream QVarLengthArray objects. [ChangeLog][QtCore][QVarLengthArray] Can now be output via QDebug streaming. Change-Id: I12f7670e32029fa8c96b446e9a98ebf3b9732d0d Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QWindowsPipeWriter: centralize write result handlingAlex Trotsenko2021-06-122-36/+29
| | | | | | | | | | Both code paths (write() for the main thread and waitCallback() for the worker thread) use the same logic when processing write results. To avoid code duplication, consolidate the common part for both threads in the startAsyncWriteLocked() function. Change-Id: Ie2663b2ed221e2797a1ecbdb3fcee0ee8f030cc0 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QLocalSocket/Win: avoid double buffering on writeAlex Trotsenko2021-06-094-9/+36
| | | | | | | | | As QWindowsPipeWriter now maintains a chunk queue, there is no need to use the internal QIODevice buffer and wait for the previous operation to complete. Change-Id: Id4d54edfe920aeb4a534980cb0cc85a56c067a70 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Switch-ify QFSFileEngine::fileName and update implementationKarsten Heimrich2021-06-081-27/+35
| | | | | | | Adapt to coding guidelines and use raw string literals. Change-Id: Ice9a87cafb22e01a361ad44221d561a298e5af05 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Implement QFileInfo::junctionTarget(), adjust auto-testKarsten Heimrich2021-06-059-2/+80
| | | | | | | | | | | | The change in 004e3e0dc2cab4a4534d2ed3ace41aad6bfbe45d introduces Windows junction awareness, though users were still unable to resolve the junction target. This change adds the ability to solve this. Fixes: QTBUG-93869 Change-Id: I9f4d4ed87b92e757f7b6d8739e2a61b58c096f63 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Unify behavior for long path or UNC prefix removalKarsten Heimrich2021-06-054-40/+34
| | | | | | | | | | | | | Split the code out of QDir::fromNativeSeparator into a separate reusable function to remove the above-mentioned prefixes. Fixes and unifies behavior if the prefix was given with slashes instead of backslashes. Add a couple more test cases. Fixes: QTBUG-93868 Pick-to: 5.15 6.0 6.1 Change-Id: Ibd94ae283e2fb113f9c2db97475fbc7d89522bbf Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* QProcess: untangle platform-specific detailsAlex Trotsenko2021-06-044-124/+131
| | | | | | | | | - add missing #ifdef in header file; - split some functions (writeData(), _q_canWrite(), cleanup()) into their platform-specific implementations. Change-Id: I4e7c1c377ec8468ed120d38acf2543eef9316c01 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcess: refine 'Channel' structureAlex Trotsenko2021-06-032-19/+12
| | | | | | | | | | - exclude unused notifier pointer on Windows; - use default initialization for members; - avoid bit fields in declarations as there are extra padding bytes anyway. Change-Id: I2e03c4c269c885c90c0a6d18b8a935885f4b3feb Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Introduce QProcessPrivate::closeChannels()Alex Trotsenko2021-05-314-15/+16
| | | | | | | Avoid duplicating code for both platforms. Change-Id: Iae00023672b63e8539cf824fa3aaaff2bf9ae0c5 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Consolidate debug string generationAlex Trotsenko2021-05-314-87/+59
| | | | | | | | | | | | | | Several QIODevice subclasses use the qt_prettyDebug() function to get a printable representation of the buffer data for debug output. Rather than having this feature statically implemented in each respective file, this patch introduces a generic function in the QtDebugUtils namespace. Accordingly, some inaccuracies in the use-cases have been corrected. Change-Id: I1a8465cab08c8acf5fdcdba5085182511b1cbb7b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Clarify that QLoggingCategory works independent of compiler build typeKai Köhne2021-05-271-1/+8
| | | | | | | | | Also mention exception for internal categories starting with 'qt.' Fixes: QTBUG-93852 Change-Id: Iff8657a31074ee70cba25f6acdccb5ba4b1d3b01 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrl: use QFlags::toInt / qToUnderlyingGiuseppe D'Angelo2021-05-231-8/+8
| | | | | | | | | | | In preparation for blocking QFlags->int conversions. The existing casts to uint are wrong, in the general case, as the enumeration might actually be backed by signed integers; that makes them fail to compile. Port them to toInt(). For symmetry, also use qToUnderlying. Change-Id: I851544f6ba05295fa5f6c5cc355b9de0f1362e2b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProcess/Unix: fix build in debug modeAlex Trotsenko2021-05-231-1/+1
| | | | | | | qprocess_unix.cpp:633:55: error: ‘i’ was not declared in this scope Change-Id: I152fbd9df6e9d3f31e2c2c8b23a3c1ab87aa237a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix QUrl::fromLocalFile with long path prefixKarsten Heimrich2021-05-191-2/+20
| | | | | | | | | | | | After commit 3966b571 the function was kinda broken already, though this got unnoticed since it was not covered by an the auto-test. This commit adds another test case with Windows native separators and removes the use of QDir::fromNativeSeparators. Instead use the original code from QDir::fromNativeSeparators to replace the backslashes. Pick-to: 5.15 6.0 6.1 Change-Id: I190560d0e75cb8c177d63b142aa4be5b01498da2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QLocalSocket/Win: fix closed state detection in waitFor...() functionsAlex Trotsenko2021-05-181-8/+11
| | | | | | | | | | | A delayed close should only be completed in the _q_bytesWritten() slot as a confirmation of a successful write operation on the socket. Otherwise, a failed write operation may cause the socket to be closed unexpectedly within the waitFor...() function, which may result in a malfunction. Change-Id: I14cff26734f64a89090b6b5c13037466a6400597 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QFile: code tidiesGiuseppe D'Angelo2021-05-172-8/+8
| | | | | | | | | | There's no need of converting a QFlags to int in openExternalFile's signature; just use the flag. Also, avoid an implicit QFlags->bool conversion by using testAnyFlag. Change-Id: Ia2d560bce235c842745d8a6a5fb5d8ac0851fc47 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Windows QFSFileEngine: avoid some QFlags implicit conversionsGiuseppe D'Angelo2021-05-171-2/+2
| | | | | | | Go through fromInt/toInt instead. Change-Id: I73097e21f59f9e8eb2c9714e22084af0787a53d5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFileSystemMetaData: code tidiesGiuseppe D'Angelo2021-05-171-13/+15
| | | | | | | | | | Turn some implicit conversions into calls to QFlags::testAnyFlag. In one case, move some code using QFlags operators *after* such operators have been declared by the right macro. Change-Id: Ib5713f028ce74d1c9054b87cc12eea5715f2bc94 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFSFileEngine: code tidiesGiuseppe D'Angelo2021-05-171-2/+2
| | | | | | | Turn a couple of implicit conversions into calls to QFlags::testAnyFlag. Change-Id: I21a0b4c1644986a98a2d0d54ae4b95f9fdc92841 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QIODevice: code tidiesGiuseppe D'Angelo2021-05-161-1/+1
| | | | | | | Turn an implicit conversion into a call to QFlags::testAnyFlag. Change-Id: Idbd80bb6a9b5d84952b76d8d7544f617fe693b91 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QSaveFile: code tidiesGiuseppe D'Angelo2021-05-161-1/+1
| | | | | | | | | | | | | | Turn a cast into a call to QFlags::toInt(), plus a cast. This is in preparation for a future patch that will remove the implicit conversion. So why not casting directly? Because we don't know if the QFlags is backed by int or uint, so using the wrong cast won't compile; and we MUST pass unsigned because of the %x specifier. Granted, one could've used a static_assert, but I prefer a more flexible and idiomatic solution. Change-Id: I32a3e0ed69b925e8d56268ec84d9e668ca540188 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDir: remove an unneeded QFlags->int conversionGiuseppe D'Angelo2021-05-161-6/+6
| | | | | | | | Just use the original QFlags. Drive by, use testFlag to check if it contains a given value or not. Change-Id: I4d5e8454df33a3f4727855d55f7587143450dda6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDir(Iterator): code tidiesGiuseppe D'Angelo2021-05-162-13/+13
| | | | | | | | | | | | | * Turn some `flags & bit` statements that rely on QFlags->int->bool implicit conversions, into some more idiomatic `return flags.testAnyFlag(bit)`. This is in preparation for a future patch, and to avoid inserting casts (return statements do not contextually convert to bool). * Remove a magic constant, replacing it by the symbolic one. Change-Id: I62fc2b2bf6f0ab8fad121edd19cb2ea0d9e3582a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>