summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
Commit message (Collapse)AuthorAgeFilesLines
* Improve readability of code that uses the Qt signed size typev5.10.0-rc2Simon Hausmann2017-11-282-4/+4
| | | | | | | | | | | | | | | | | During the container BoF session at the Qt Contributor Summit 2017 the name of the signed size type became a subject of discussion in the context of readability of code using this type and the intention of using it for all length, size and count properties throughout the entire framework in future versions of Qt. This change proposes qsizetype as new name for qssize_t to emphasize the readability of code over POSIX compatibility, the former being potentially more relevant than the latter to the majority of users of Qt. Change-Id: Idb99cb4a8782703c054fa463a9e5af23a918e7f3 Reviewed-by: Samuel Gaist <samuel.gaist@edeltech.ch> Reviewed-by: David Faure <david.faure@kdab.com>
* Fix namespaced linux buildsAllan Sandfeld Jensen2017-11-282-1/+8
| | | | | | | | | Using "struct statx" as argument type is forward declaration which then will expect the namespace where it was first encountered. Change-Id: I2d4ba930bd5b4e264228f2549bd6ef75e5cf3a67 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix the build if st_atimensec is definedThiago Macieira2017-11-231-2/+7
| | | | | | | | | | | | | It's a trick used by some C libraries to keep compatibility with BSD extensions while supporting POSIX.1-2008 API. st_atimensec is defined as st_atim.tv_nsec, so the code would expand to invalid C++ In substitution of 'template<class T> typename std::enable_if<((&T::st_atim.tv_nsec), true), long long int>::type{anonymous}::GetFileTimes::atime(const T&, int) [with T = stat]': error: invalid use of non-static data member 'stat::st_atim' Change-Id: I38341f8155354cc4a776fffd14e20f4fc0f6d5bb Reviewed-by: BogDan Vatra <bogdan@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QTemporaryFile: fix issues with removing a file twiceThiago Macieira2017-11-234-5/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The assertion in isUnnamedFile() we had was incorrect after the file was removed, since we cleared the name and possibly reset back to the template. Since ~QTemporaryFile() calls remove(), this was easy to trigger if you attempted to remove the temp file and leave QTemporaryFile like that. Take this opportunity to add to the docs of setAutoRemove() explaining the possibility of unnamed files. #7 0x00007f69bcc2b50e in qt_assert ( assertion=assertion@entry=0x7f69bcf194a0 "unnamedFile == d_func()->fileEntry.isEmpty()", file=file@entry=0x7f69bcf19458 "io/qtemporaryfile.cpp", line=line@entry=514) at global/qglobal.cpp:3123 #8 0x00007f69bcd672cf in QTemporaryFileEngine::isUnnamedFile (this=this@entry=0x55cd60644df0) at io/qtemporaryfile.cpp:514 #9 0x00007f69bcd683f7 in QTemporaryFileEngine::remove (this=0x55cd60644df0) at io/qtemporaryfile.cpp:396 #10 0x00007f69bcd48654 in QFile::remove (this=this@entry=0x7fffb393f7e0) at io/qfile.cpp:513 #11 0x00007f69bcd6653b in QTemporaryFile::~QTemporaryFile (this=0x7fffb393f7e0, __in_chrg=<optimized out>) at io/qtemporaryfile.cpp:719 Change-Id: I57a1bd6e0c194530b732fffd14f4ed28ca8185b2 Reviewed-by: Andreas Hartmetz <ahartmetz@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFileSystemEngine/Linux: fix when qt_lstatx() succeedsThiago Macieira2017-11-201-15/+16
| | | | | | | | | | | | | | When qt_lstatx() succeeds and the target is not a link, we'd erroneously mark the file as non-existent during the pass to check qt_statx(). All flags besides the file's modes were cleared. This is unit-tested, but only happens on Linux kernels 4.12 or later. It didn't happen to me because I already had this fix applied as part of a later change relating to QSystemResult. Task-number: QTBUG-64514 Change-Id: I938b024e38bf4aac9154fffd14f893506a1ef55b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge 5.10 into 5.10.0Oswald Buddenhagen2017-11-205-9/+40
|\ | | | | | | Change-Id: Ibfbaa8ef89cf45b87a2c65f1da4a708e5464f259
| * QIODevice: do not clear error string on closeAlex Trotsenko2017-11-161-1/+1
| | | | | | | | | | | | | | | | | | Keeping a description of the last device error is a more informative to the user than forcing the string to 'Unknown error'. Change-Id: Ie98fe1c94f24279fb633ce950bbe16450b0efdbd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
| * Merge remote-tracking branch 'origin/5.9' into 5.10Liang Qi2017-11-092-3/+35
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/gui/kernel/qwindow.cpp src/plugins/platforms/cocoa/qcocoawindow.mm src/plugins/platforms/windows/qwindowssystemtrayicon.cpp src/plugins/platforms/xcb/qxcbconnection_xi2.cpp tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp tests/auto/widgets/kernel/qaction/tst_qaction.cpp Change-Id: Ifa515dc0ece7eb1471b00c1214149629a7e6a233
| | * QFilesystemWatcher/Windows: Use event dispatcher of threadFriedemann Kleint2017-11-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, the native event filter listening on removable drivers was installed on QCoreApplication::eventDispatcher() which led to a mismatch when launched from a non-GUI thread since ~QAbstractNativeEventFilter() removes itself from QAbstractEventDispatcher::instance(). Amends 45580aa92557caa4f3f5be783573ddb80602e494, e612fe8d47bc0fe762668617a5189117ad1aee15. Task-number: QTBUG-64171 Change-Id: Icbe289bd585f124d66989d0cd574040b986e680c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | * QStorageInfo: Properly decode labels from /dev/disk/by-labelChristian Ehrlicher2017-11-041-1/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | udev encodes the labels for /dev/disk/by-label/ with ID_LABEL_FS_ENC which is done with blkid_encode_string(). This function encodes some unsafe 1-byte utf-8 characters as hex (e.g. '\' or ' ') Task-number: QTBUG-61420 Change-Id: If82f4381d348acf9008b79ec5ac7c55e6d3819de Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * | Change almost all other uses of qrand() to QRandomGeneratorThiago Macieira2017-11-082-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The vast majority is actually switched to QRandomGenerator::bounded(), which gives a mostly uniform distribution over the [0, bound) range. There are very few floating point cases left, as many of those that did use floating point did not need to, after all. (I did leave some that were too ugly for me to understand) This commit also found a couple of calls to rand() instead of qrand(). This commit does not include changes to SSL code that continues to use qrand() (job for someone else): src/network/ssl/qsslkey_qt.cpp src/network/ssl/qsslsocket_mac.cpp tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp Change-Id: Icd0e0d4b27cb4e5eb892fffd14b5285d43f4afbf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | QTemporaryFile: hide the O_TMPFILE feature behind a check for linkat()Thiago Macieira2017-11-111-1/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some Linux libc (I'm looking at you, Bionic) use the system call but don't expose it to userspace. We could use syscall() to make the system call, but instead I decided to penalize users of those libc by not having the feature. It's probably a good thing, since there were likely to be more problems with Android anyway and I don't have an environment to debug. Task-number: QTBUG-64154 Change-Id: I57a1bd6e0c194530b732fffd14f3007a1062d935 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into 5.10Liang Qi2017-10-302-11/+9
|\| | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/windows/qwindowswindow.cpp tests/auto/widgets/kernel/qaction/tst_qaction.cpp Change-Id: Ia017a825ed2ca2d53ac586f4ae48df6f65818d40
| * QUrl: make sure setPort(nonnegative) is taken as part of authorityThiago Macieira2017-10-261-8/+6
| | | | | | | | | | | | | | | | | | | | | | There were a couple of corner cases where doing setPort() would result in QUrl thinking that an authority was not present. Since the full URL parsing implies that a host is always present if the authority is present, then we also imply that setting the port number makes the host be present too. Change-Id: I69f37f9304f24709a823fffd14e67c12da18d69f Reviewed-by: David Faure <david.faure@kdab.com>
| * Remove duplicate qnx from the platform file selector namesLiang Qi2017-10-241-3/+3
| | | | | | | | | | | | | | | | Update the QFileSelector tests for QNX. Co-authored-by: James McDonnell <jmcdonnell@blackberry.com> Change-Id: I68a8fde86725596323b539433287ac1a18fac1eb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QFileSystemEngine: Fix renameat2() failures on non-local filesystemsThiago Macieira2017-10-291-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The RENAME_NOREPLACE flag is supported for all Linux local filesystems, since that can be easily checked by the VFS layer (it knows which files exist and which ones don't). For non-local filesystems, the backend needs support and that might need server-side support too. So we may get EINVAL errors for those, in which case we fall back to link/unlink, which in turn can fall back to rename(). EINVAL can also happen if we attempt to make a directory a subdirectory of itself. In that case, we will attempt to link() it, which will result in EPERM as we can't hardlink directories. Then we try rename() again, which should result in the expected EINVAL. Task-number: QTBUG-64008 Change-Id: Icaa86fc7b54d4b368c0efffd14f09ca23602dd2e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into 5.10Liang Qi2017-10-232-0/+11
|\| | | | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/direct2d/direct2d.pro src/plugins/platforms/ios/qiosclipboard.mm src/plugins/platforms/windows/windows.pro Change-Id: Idffa03b3990bd642784f528821c5446b2e1008ef
| * winrt: Fully initialize CREATEFILE2_EXTENDED_PARAMETERS structOliver Wolff2017-10-201-0/+3
| | | | | | | | | | | | | | | | | | Not properly initializing all members of the extended parameter struct will cause an "invalid handle specified" exception on use. Task-number: QTBUG-63883 Change-Id: Ic3a58df864c9e29ccbadc04bd71c18c8ef34374c Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
| * Doc: State that qDebug and friends are thread-safeKai Koehne2017-10-171-0/+8
| | | | | | | | | | | | | | | | | | | | There's a common misconception that qDebug and friends are not thread-safe, so let's explicitly state this. Change-Id: I48d4ab8983017a9f2e7c9932a49ed573baa22929 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.9' into 5.10Liang Qi2017-10-161-9/+22
|\| | | | | | | Change-Id: I3cf73c53cf131d0babfb558c2507bed0e0fc5f08
| * QUrl: re-fix the setPath("//path") case leading to scheme://pathThiago Macieira2017-10-061-9/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commits aba336c2b4ad8926dc8a000718bbb7f8a6d5a72d (in Qt 5.2) and aba336c2b4ad8926dc8a000718bbb7f8a6d5a72d (in 5.6) both tried to deal with this problem, with different levels of success. This is the third attempt (and hopefully the charm). Instead of modifying the path that the user provides, go straight ahead and declare it invalid. This is supported by RFC 3986, which declares this expansion impossible: relative-part = "//" authority path-abempty / path-absolute / path-noscheme / path-empty path-abempty = *( "/" segment ) path-absolute = "/" [ segment-nz *( "/" segment ) ] path-noscheme = segment-nz-nc *( "/" segment ) The "path-abempty" and "path-noscheme" cases are the two issues we already handle. This commit adds the third one: path-absolute, which requires that the first segment of the path be of non-zero length. That is, it is now possible again to have http://example.com//path constructed piece-wise, without it producing http://example.com/path. Additionally, it catches the case of http://example.com//path parsed from full URL then followed by setAuthority(""). Change-Id: I69f37f9304f24709a823fffd14e67a5e7212ddcd Reviewed-by: David Faure <david.faure@kdab.com>
* | QLockFile: don't use QCoreApplication::applicationName()Thiago Macieira2017-10-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | That was stupid for two reasons. First, applicationName() can be changed by the user by calling QCoreApplication::setApplicationName(), so if that happens, we won't be able to properly identify a lock belonging to a given application because the name changed. Second, because applicationName() is not what we compare to. Instead, let's use processNameByPid() on both content creation and verification. [ChangeLog][QtCore][QLockFile] Fixed a bug that would cause QLockFile mis-identify valid lock files as stale if the application name was set with QCoreApplication::setApplicationName(). Change-Id: I0b48fc8e90304e0dacc3fffd14e912a5c98c87e7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | QLockInfo: Centralize the management of the lock file's contentsThiago Macieira2017-10-064-77/+100
| | | | | | | | | | | | | | | | | | We duplicated both the creation of the contents and the check if the file was stale. Centralize everything in qlockfile.cpp. Change-Id: I0b48fc8e90304e0dacc3fffd14e91174af79841f Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | QLockFile/Unix: drop the use of fcntl(F_SETLK)Thiago Macieira2017-10-062-73/+44
| | | | | | | | | | | | | | | | | | | | | | | | F_SETLK is bad. Explanation in the comment. And flock(2) does work with NFS on Linux, so let's just stick to that, which is simpler. We only use the file locks when we attempt to delete an apparently stale lock: that is, for a lock file that is at least staleLockTime old. Change-Id: I0b48fc8e90304e0dacc3fffd14e908c8c4c9d59b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: David Faure <david.faure@kdab.com>
* | Clean up OS version checks for Apple platformsJake Petroules2017-09-291-10/+2
| | | | | | | | | | | | | | | | | | | | Convert QSysInfo/QOperatingSystemVersion to __builtin_available where required or possible, or to QOperatingSystemVersion where __builtin_available cannot be used and is not needed (such as negated conditions, which are not supported by that construct). Change-Id: I83c0e7e777605b99ff4d24598bfcccf22126fdda Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QFileSystemEngine: Remove unneeded test for relative symlinkOrgad Shaneh2017-09-281-2/+0
| | | | | | | | | | | | | | symLinkTarget should always return absolute path. Change-Id: Id0078924d2f0befdea91e652a6c7775707c1b3c8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QFileSystemEngine: Minor cleanup in unixOrgad Shaneh2017-09-281-7/+2
| | | | | | | | | | Change-Id: I4a123484ea1f5e53af85a52e86d4a80cef1cd7bc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Don't read the statx struct in case of failureSérgio Martins2017-09-271-2/+5
| | | | | | | | | | Change-Id: I62d98e4463003a1da8f28318d82635f6e0b2cc8c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QRandomGenerator: update API to better nameThiago Macieira2017-09-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | "generate" is better than "get", and we already have "generate(it, it)" which uses std::generate(). This changes: - get32() → generate() - get64() → generate64() and QRandomGenerator64::generate() - getReal() → generateDouble() Change-Id: I6e1fe42ae4b742a7b811fffd14e5d7bd69abcdb3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into 5.10Liang Qi2017-09-201-0/+1
|\| | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/styles/mac/qmacstyle_mac.mm src/widgets/util/qcompleter.cpp src/widgets/widgets/qmainwindowlayout.cpp src/widgets/widgets/qmdisubwindow.cpp Change-Id: If0e96981af07ce36ac68f2e69211bc2120f93973
| * Add missing pwd.h includeJake Petroules2017-09-181-0/+1
| | | | | | | | | | | | | | | | | | This file uses functions declared in this header, and it is not pulled in transitively on all platforms. Change-Id: I6654118883a8dc22dacf1beb7b9b1c662719d25c Reviewed-by: Tuomas Heimonen <tuomas.heimonen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.9' into 5.10Liang Qi2017-09-061-4/+9
|\| | | | | | | | | | | | | | | | | | | Conflicts: examples/opengl/qopenglwidget/main.cpp src/3rdparty/pcre2/src/pcre2_printint.c src/plugins/platforms/cocoa/qnsview.mm src/widgets/widgets/qcombobox.cpp Change-Id: I37ced9da1e8056f95851568bcc52cd5dc34f56af
| * Fix resolution of relative links on WindowsOrgad Shaneh2017-09-041-4/+9
| | | | | | | | | | | | | | | | | | | | [ChangeLog][QtCore][QFileInfo] Relative symbolic links on Windows are now resolved to their absolute path by symLinkTarget(). Task-number: QTBUG-62802 Change-Id: I5826517130bd389aef994bf3f4b6d99b2a91b409 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-08-315-22/+46
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/examples.pro qmake/library/qmakebuiltins.cpp src/corelib/global/qglobal.cpp Re-apply b525ec2 to qrandom.cpp(code movement in 030782e) src/corelib/global/qnamespace.qdoc src/corelib/global/qrandom.cpp src/gui/kernel/qwindow.cpp Re-apply a3d59c7 to QWindowPrivate::setVisible() (code movement in d7a9e08) src/network/ssl/qsslkey_openssl.cpp src/plugins/platforms/android/androidjniinput.cpp src/plugins/platforms/xcb/qxcbconnection.cpp src/plugins/platforms/xcb/qxcbconnection_xi2.cpp src/widgets/widgets/qmenu.cpp tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp Change-Id: If7ab427804408877a93cbe02079fca58e568bfd3
| * QFileInfo: Clarify documentation on symlinksFriedemann Kleint2017-08-291-7/+11
| | | | | | | | | | | | | | | | Explain symbolic links vs shortcuts. Change-Id: I12176616be72c97607ee1f441d1ea05af5e9e549 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
| * Doc: Fix exampleRobert Loehning2017-08-281-2/+2
| | | | | | | | | | Change-Id: Ic678b69c6c9820701c4cc10c7797f599e5d71b7a Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
| * Fix resolution of relative symlinks from relative path on unixOrgad Shaneh2017-08-271-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider the following: /root/target - a file /root/path/link -> ../target /root/path/other/exe - executable Running from /root/path/other. exe is: #include <QDebug> #include <QFileInfo> int main() { qDebug() << QFileInfo("../link").symLinkTarget() return 0; } The link references /root/target, but the current output is /root/path/target. The link doesn't depend on the PWD. It depends on its own directory. Change-Id: I61e95018154a75e0e0d795ee801068e18870a5df Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * QFileInfo: Fix typo in docOrgad Shaneh2017-08-261-1/+1
| | | | | | | | | | | | Change-Id: Id1051f08a870461b172b646c126eb44e8addc114 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jake Petroules <jake.petroules@qt.io>
| * Fix compilation on 64-bit CPUs when QPROCESS_DEBUG is enabledDavid Faure2017-08-201-4/+6
| | | | | | | | | | | | | | Change-Id: Iad4bea50805b59bd6e985f5830315a7437880b99 Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io> Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * QProcess/Unix: fix possible race condition inside waitForXXX() loopsAlex Trotsenko2017-08-181-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calling QCoreApplication::processEvents() from a slot connected to the readyRead() signal might cause desynchronization in the waitForXXX() loop, if the process has been finished during the event processing. This results in unnecessary timeouts and causes waitForFinished() to fail unexpectedly. So, a proposed solution is to check the state on each iteration of the loop, as Windows implementation does. Given issue is tested by tst_QProcess::processEventsInAReadyReadSlot() which was unstable in CI. Task-number: QTBUG-62584 Change-Id: I7438cf67b0163bbf49314008a9dc660c0977fb7b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * Android: Fix compile with unified headersBogDan Vatra2017-08-172-2/+10
| | | | | | | | | | | | | | | | Unified headers now defines _POSIX_THREAD_SAFE_FUNCTIONS but not all libc functions are available in all Android API versions. Change-Id: I01c94f0b89e7f8aa8575e7bbda28d9fe41a68ff1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Simplify QDataStream::skipRawData()Alex Trotsenko2017-08-311-25/+6
| | | | | | | | | | | | | | ... by using the new QIODevice::skip() function. Change-Id: I943c4feb896d677f3150da542950595d7f485e75 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QProcess: add docs that the PID from startDetached() may be recycledThiago Macieira2017-08-291-2/+6
| | | | | | | | | | Change-Id: I209fcd5dbc2b4e5381cffffd14de2742eb1d8cd7 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* | Introduce QIODevice::skip()Alex Trotsenko2017-08-273-0/+126
| | | | | | | | | | | | | | | | | | | | [ChangeLog][QtCore][QIODevice] Added skip() method to improve performance in read operations. Change-Id: I79068a3e9df108756abe37ba3d431e27e7413621 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QTemporaryFile: Add support for Linux's O_TMPFILEThiago Macieira2017-08-233-15/+198
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | That means a file is never created, unless you ask for the name. There's no chance of left-over temporary files being left behind. QSaveFile also benefits from this, since the save file is not present on disk until commit(). Unfortunately, QSaveFile must go through a temporary name because linkat(2) cannot overwrite -- we need rename(2) for that (for now). [ChangeLog][Important Behavior Changes][QTemporaryFile] On Linux, QTemporaryFile will attempt to create unnamed temporary files. If that succeeds, open() will return true but exists() will be false. If you call fileName() or any function that calls it, QTemporaryFile will give the file a name, so most applications will not see a difference. Change-Id: I1eba2b016de74620bfc8fffd14cc843e5b0919d0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | QFileSystemEngine::cloneFile: expand the Linux cloning processThiago Macieira2017-08-221-3/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | FICLONE only works on (currently) btrfs and xfs, and then only if it's the same mount, so it's of very limited use. There are a couple other techniques we may try that do not involve I/O through user-space, though not immediate: - sendfile(2) can be used on regular files, even across mountpoints - sendfile(2) can be used on block devices too, but we need to get the device's size first - splice(2) can be used on pipes (FIFOs) We only implement the first technique (earlier iterations of this patch implemented all). Change-Id: I81480fdb578d4d43b3fcfffd14d4b47cd70495a3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | QFileSystemEngine::cloneFile: add support for fcopyfile(3) on macOSThiago Macieira2017-08-221-1/+16
| | | | | | | | | | | | | | | | For some reason, fcopyfile(3) works on directories, so we need to make we aren't operating in one. Change-Id: I81480fdb578d4d43b3fcfffd14d4f2f485348515 Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* | Move the file-cloning code from QFSFileEngine to QFileSystemEngineThiago Macieira2017-08-223-9/+24
| | | | | | | | | | Change-Id: I02d22222fff64d4dbda4fffd14d1c1bbf48385ff Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | QProcessPrivate::tryReadFromChannel(): remove dead codeAlex Trotsenko2017-08-171-4/+1
| | | | | | | | | | | | | | 'readBytes == 0' condition is checked in the code above. Change-Id: I9448f47939b174fdef9f0cd5413254d41a8b4273 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QFileSystemEngine: verify that the file name isn't emptyThiago Macieira2017-08-173-8/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Making system calls with empty file names is not a good idea. When you run qmake $srcdir, you see this in strace: stat("", 0x7ffed229e250) = -1 ENOENT (No such file or directory) (twice) I've also inlined the isEmpty() function for better code generation. Some functions take QSystemError and some don't. That needs to be corrected at some point, possibly with something like std::expected. Change-Id: I1eba2b016de74620bfc8fffd14ccbfa162f93631 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>