summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfilesystemengine_win.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QAbstractFileEngine: remove member FileTime and use QFile::FileTimeAhmad Samir2024-03-211-4/+4
| | | | | | | | | This is probably a remnant from when QAbstractFileEngine was public API since it's been changed to private API, just use QFile::FileTime. Pick-to: 6.7 Change-Id: I60d3d4ff811f95434b81d5ca115f5d43cfff8b15 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Create class documentation for QNtfsPermissionCheckGuardMate Barany2023-12-061-18/+0
| | | | | | | | | | ...and document the related functions as well. Pick-to: 6.6 Fixes: QTBUG-116350 Change-Id: I038d59f6af46b29e2123bc8b6c24ff4ffea78bbf Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* QFile::moveToTrash: fix error reporting on WindowsVolker Hilsheimer2023-09-241-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a move-to-trash operation failed, e.g. because the file was opened by another process (or QFile), then the moveToTrash function would still return true. MSDN documents the IFileOperation::PerformOperations to return whether the operation succeeded, but evidently this is only a statement about the execution of queued up operations, not a statement about any of the operations' success. If the operation succeeded is reported by an HRESULT parameter of the IFileOperationProgressSink::PostDeleteItem implementation, and we ignored that parameter so far. Check it via the SUCCEEDED macro, and set a boolean sink variable based on that, which we can inspect to return the correct value. Augment the test case by opening those files we create ourselves, and if that fails (which it will on Windows, but not necessarily on other platforms), then try again after closing the file. If the first attempt succeeded, then the source file must also be gone. Pick-to: 6.6 6.5 6.2 5.15 Fixes: QTBUG-117383 Done-With: Thiago Macieira <thiago.macieira@intel.com> Change-Id: Icb82a0c9d3b337585dded622d6656e07dee33d84 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Deprecate usage of qt_ntfs_permission_lookupMate Barany2023-02-141-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | With the introduction of a new atomic variable the users should use the class QNtfsPermissionCheckGuard or the helper functions - qEnableNtfsPermissionChecks() - qDisableNtfsPermissionChecks() - qAreNtfsPermissionChecksEnabled() to enable/disable permission checks instead of manually managing the variable qt_ntfs_permission_lookup (which is a non-atomic variable and as such prone to data races). Also moved the variable qt_ntfs_permission_lookup to qfile.h to make it clash with the user-side declarations the documentation suggested to use (and it is probably also a better fit thematically anyway). [ChangeLog][QtCore][Deprecation Notice] Deprecated the variable qt_ntfs_permission_lookup to avoid race conditions while enabling or disabling permission checks. It can be replaced by the RAII class QNtfsPermissionCheckGuard or with the functions qEnableNtfsPermissionChecks(), qDisableNtfsPermissionChecks() and qAreNtfsPermissionChecksEnabled(). Fixes: QTBUG-105804 Change-Id: I93a563864ffb3f9945551c34004d8ca393603b25 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Avoid potential data races caused by qt_ntfs_permission_lookupMate Barany2023-02-081-3/+42
| | | | | | | | | | | | | | | | | qt_ntfs_permission_lookup is a global, non-atomic variable which could cause problems in case of multiple threads. Introduce a new atomic variable to handle permission lookups but instead of manual incrementation/decrementation, implement a class to manage the variable. Since the atomic variable is not directly available to the user, implement helper functions to increase/decrease/check the status of the variable. Task-number: QTBUG-105804 Change-Id: If6cbcdd653c7f50ad9853a5c309e24fdeb520788 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add QFileInfo::readSymLink() to read the raw link pathWang Fei2022-12-231-6/+13
| | | | | | | | | | | | | The existing symLinkTarget() always resolves the symlink target to an absolute path; readSymLink() provides access to the relative path when that is how the symlink references its target. [ChangeLog][QtCore][QFileInfo] Added readSymLink() to read the symlink's raw target, without resolving to an absolute path. Fixes: QTBUG-96761 Change-Id: I360e55f1a3bdb00e2966229ea8de78cf29a29417 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Adapt corelib to use QTimeZone in place of Qt::TimeSpecEdward Welbourne2022-12-091-1/+1
| | | | | | | | | This saves (mostly in corelib/time/) some complications that used to arise from needing different code-paths for different time-specs. Task-number: QTBUG-108199 Change-Id: I5dbd09859fce7599f1ba761f8a0bfc4633d0bef9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QComHelper class for dealing with COM on WindowsTor Arne Vestbø2022-08-291-22/+7
| | | | | | | | | | | | | | | Unifies our approach to calling CoInitializeEx and CoUninitialize, removing a lot of boilerplate in the process, and also fixes a few bugs where we would incorrectly balance our calls to CoInitializeEx and CoUninitialize. The optimistic approach of qfilesystemengine_win.cpp of calling CoCreateInstance without initializing the COM library explicitly has been removed, as calling CoInitializeEx should be a noop in the situation where it's already been loaded. Change-Id: I9e2ec101678c2ebb9946504b5e8034e58f1bb56a Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* QtBase: Windows: Replace some deprecated API usagesYuhang Zhao2022-08-031-3/+3
| | | | | | | | | | | | Microsoft recommends to use CoInitializeEx() and SetWindowLongPtr()/GetWindowLongPtr() in new code. Use COINIT_DISABLE_OLE1DDE to avoid overhead of initializing and using obsolete technology. Pick-to: 6.4 Change-Id: I9d16943e864d4487dd4f46fd9325579c298c52b9 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Fix typos in docs and commentsKai Köhne2022-06-151-2/+2
| | | | | | | | | Found by codespell Pick-to: 6.4 Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QFileSystemEngine/Win: simplify codeThiago Macieira2022-05-301-15/+12
| | | | | | | | | | | | | | | | We don't need two or even three buffers for the current directory. In the worst case, we had a 260-byte buffer on the stack, a larger one on the heap (new[]/delete[]) and then a copy of it in QString. Now, we shall have only one and it could be "gifted" to QFileSystemEntry via std::move() (requires separate patch to take the QString by rvalue- ref). Pick-to: 6.3 Change-Id: Ibcde9b9795ad42ac9978fffd16f2bb2a443697d6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* QFileSystemEngine/Win: fix incorrect buffer size in currentPath()Thiago Macieira2022-05-301-1/+1
| | | | | | | | | | | We've just allocated a buffer of 'size' size, which is bigger than PATH_MAX, but told GetCurrentDirectory() that its size is PATH_MAX. Fixes: QTBUG-103852 Pick-to: 5.15 6.2 6.3 Change-Id: Ibcde9b9795ad42ac9978fffd16f2ba2cd8712cb7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* 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>
* MS QNativeFilePermissions: fix unused member and capture warningsEdward Welbourne2022-03-311-9/+4
| | | | | | | | | | | | | | | | | | | | | Two members are only used in code that's conditioned on pseudo-feature fslibs, which was defined in qfilesystemengine_win.cpp; move that definition to qfiledevice_p.h so that the members's existence can be conditioned on the same #if-ery as their use. The bootstrap build was broken by the warning. In the code that uses them, a lambda captured this but didn't use it, causing the non-bootstrap build to get a warning (hence error) and fail. So remove the unnecessary capture. Also suppressed warnings on an unused function. This amends commit 174af05400f6344a11f4aa2228244c954cbbca97 Pick-to: 6.3 Task-number: QTBUG-79750 Change-Id: Ib29f3200b7736bc07df68aeec4fc6f568c8f4ddb Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
* qfilesystemengine_win: Fix compilation with namespacesMårten Nordheim2022-03-291-5/+4
| | | | | | | | | | | The original using is outside QT_NAMESPACE, so it is not correctly picked up by various parts of the code. Simply moving it inside QT_(BEGIN|END)_NAMESPACE revealed that the namespace (and thus scope) is closed and re-opened. in the file, so fix that too. Change-Id: I704f164b5705b539dbdf25b7743f5e339c016600 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QtCore: replace QLatin1String/QLatin1Char with _L1/u'' where applicableSona Kurazyan2022-03-251-30/+31
| | | | | | | | | | | As a drive-by, did also minor refactorings/improvements. Task-number: QTBUG-98434 Change-Id: I81964176ae2f07ea63674c96f47f9c6aa046854f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
* QFile::moveToTrash: Remove support for old MinGW SDKsVolker Hilsheimer2022-03-121-5/+0
| | | | | | | | | | | | | | | SDK headers that shipped with older versions of MinGW didn't declare the IFileOperation COM interface, so the original implementation of moveToTrash included an inferior fallback that used the Shell APIs. That fallback was already removed in 6a51ff3f0d6ca6b268825b60c95ddcf972bb4d49, now remove the #ifdef'ery as well. Change-Id: Iba44df8267f5c1e3e883368d848eb9be1bd02ac3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
* Fix warnings in bootstrap lib on WindowsJoerg Bornemann2022-02-181-0/+3
| | | | | | | | | This amends commit 174af05400f6344a11f4aa2228244c954cbbca97. Pick-to: 6.3 Change-Id: Ifc11b3c332f2b7fd16074420a0d730997ae13395 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
* QDir: Add support for setting directory permissions to mkdir()Ievgenii Meshcheriakov2021-11-261-27/+279
| | | | | | | | | | | | | | 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>
* Use Authz API to query permissions info in Windows filesystem backendIevgenii Meshcheriakov2021-11-191-117/+214
| | | | | | | | | | | | | | | | | | | | | | | | | | Microsoft documentation for GetEffectiveRightsFromAclW function that was used previously has this at the top of the page: > GetEffectiveRightsFromAcl is available for use in the operating > systems specified in the Requirements section. It may be altered > or unavailable in subsequent versions. Instead, use the method > demonstrated in the example below. This says to me that the function is deprecated. In addition to that, it is not able to handle ACLs that are not in "canonical" order, returning ERROR_INVALID_ACL. Such ACLs are useful to represent POSIX permissions in Windows, and are produced by Cygwin for example. This patch uses Authz API referenced by the message quoted above. The used API is available starting from Windows XP/Windows Server 2003. This API also allowe to perform access checks given access token, and so allows to use similar code all permission checks. Task-number: QTBUG-79750 Change-Id: I8b11ff3cc83cd9ed5bfb2ce9432a375a122cdbbf Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QFileSystemEngine: Fix permissions query in Windows backendIevgenii Meshcheriakov2021-11-181-1/+1
| | | | | | | | | Make fillPermissions() correctly set OtherExecutePermission instead of OwnerExecutePermission. Pick-to: 6.2 Change-Id: I77ef3c5bc59ac6110c5a461a599d03029c70493c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QFileSystemEngine: Don't use _?W suffixesIevgenii Meshcheriakov2021-11-101-7/+7
| | | | | | | | | We don't use W suffix for most of the Windows API so there is no need to use it here either. Also remove W suffix for variables of type TRUSTEE (was TRUSTEE_W). Change-Id: Id67b772ba5d3232f882841a1e581fb1bbd392fa4 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Use nullptr to represent null pointersIevgenii Meshcheriakov2021-11-101-39/+36
| | | | | | | Replace occurrences of NULL and 0 when used for pointers. Change-Id: I485e73d22a1a85d1303f3e0967cd4e8f10ff5d33 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QFileSystemEngine: Fix some code style issues in Windows backendIevgenii Meshcheriakov2021-11-101-55/+113
| | | | | | | | | | | Wrap lines at column 101 so that it is easier to edit the file and review the changes in Gerrit. Move comments when they cannot be easily wrapped. Add curly braces to `if` statements if they became multiline. Run `git clang-format` on the file afterwards. Change-Id: Ib21afd65147a7b202e031d4a865b5f615e5ad6d8 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Remove useless blocksIevgenii Meshcheriakov2021-11-101-38/+34
| | | | | | | Don't put the code inside two blocks for no reason. Change-Id: I54b8d6fbfab50a26ddcd8ec07ba689e5094bcad3 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Bump WINVER, _WIN32_WINNT and _WIN32_IE to _WIN32_WINNT_WIN10 (0x0A00)Yuhang Zhao2021-11-101-9/+0
| | | | | | | | | | | And bump NTDDI_VERSION to 0x0A00000B (NTDDI_WIN10_CO) at the same time, to unblock the developers from accessing the latest Windows APIs. Pick-to: 6.2 Change-Id: Ifbc28c8f8b073866871685c020301f5f20dc9591 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make QDir::mkpath() return true when given an existing drive nameKarsten Heimrich2021-10-201-1/+1
| | | | | | | | | | | | Commit ed48391c592e8ba68c723e3017ac384f0c7a7c23 removed the check for ERROR_ACCESS_DENIED reported by the Windows CreateDirectory(...) function in case an existing windows drive name was passed as argument. This restores the behavior of the function which broke after 5.15. Pick-to: 6.2 Fixes: QTBUG-85997 Change-Id: Ie86188100766f7364acee57b15a250f4a2720b9f Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
* Replace 0 with nullptrKarsten Heimrich2021-10-021-2/+2
| | | | | | Change-Id: I9ee25644a3e066391e881bd2f64274909eabfcbf Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix QDir::entryList to work for directories that end with '.lnk'Karsten Heimrich2021-09-301-4/+3
| | | | | | | | | | | | | In addition to checking the .lnk extension, check that the the specified path is not a path to a directory. Pick-to: 6.2 Fixes: QTBUG-85058 Change-Id: I83cef3d94c6ffa82a88f374c5b41779e88fe40b8 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix compile with MinGW-W64 9.0.0: Redefinition of 'struct _FILE_ID_INFO'Jonas Kvinge2021-08-181-2/+2
| | | | | | | | | | | With MinGW-W64 9.0.0, _WIN32_WINNT is set to Windows 10 by default, so _FILE_ID_INFO is already defined. Fixes: QTBUG-94031 Pick-to: 6.2 Change-Id: I0b29a4a1932425e1c4079aba6768fe94460c60af Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* io: Remove version checks for versions below Win 10Mårten Nordheim2021-07-281-71/+35
| | | | | | | It's not supported. Change-Id: Ia17fc7e1d5ae785eca0a6ba530f9b9bc960605d4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Implement QFileInfo::junctionTarget(), adjust auto-testKarsten Heimrich2021-06-051-0/+20
| | | | | | | | | | | | 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-051-12/+2
| | | | | | | | | | | | | 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>
* Implement QFileSystemEngine::createLink() on MS-WinKarsten Heimrich2021-05-121-5/+33
| | | | | | | | | Fixes: QTBUG-74271 Change-Id: I9e414dd16546f65e85b5a1a6c70c40dfa4284a6f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Use Core library for qmake instead of the Bootstrap libraryAlexey Edelev2021-02-251-2/+2
| | | | | | | | | | | | | | | | | | | Move the qmake-specific logic of the QLibraryInfo class to qmake internals. 'qconfig.cpp.in' now stores information about the library info entries to keep them consistent between qmake and the Core library. qmake requires specific features enabled in the Core library, so building qmake will be skipped if the features are not enabled. All flags directly related to the qmake have been removed from Core lib. Remove all bootstrap related sections from qmake CMakeLists.txt Task-number: QTBUG-89369 Change-Id: I26de157d3bfd4a5526699296e9d46e1c180b89ae Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Adjust code format, add space after 'if'Zhang Sheng2020-11-161-15/+15
| | | | | | Change-Id: Ice081c891ff7f4b766f49dd4bd5cf18c30237acf Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: hjk <hjk@qt.io>
* Another round of replacing 0 with nullptrAllan Sandfeld Jensen2020-10-071-1/+1
| | | | | | | | | This time based on grepping to also include documentation, tests and examples previously missed by the automatic tool. Change-Id: Ied1703f4bcc470fbc275f759ed5b7c588a5c4e9f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix build with mingw gcc 9 and -Wsuggest-overrideKai Koehne2020-08-101-30/+21
| | | | | Change-Id: I780b0761a7f6b19022116b738efa7aca1378b715 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QFileInfo: Fail faster when stat'ing filepath on a disconnected driveVolker Hilsheimer2020-07-291-6/+8
| | | | | | | | | | | | | The Windows implementation of QFileSystemEngine tries hard to fill the metadata for a file, even if GetFileAttributesEx returns with error. This is good in many situations, but when the error code indicates that the drive on which the file resides has been disconnected, then we should fail quickly. Task-number: QTBUG-6039 Pick-to: 5.15 Change-Id: I7574c5a2e524e913306d0b470b4f227416442c13 Reviewed-by: Mårten Nordheim <marten.nordheim@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>
* Use QList instead of QVector in corelib implementationJarek Kobus2020-06-291-3/+2
| | | | | | | | Omitting state machine and docs for now. Task-number: QTBUG-84469 Change-Id: Ibfa5e7035515773461f6cdbff35299315ef65737 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Port QDir, QFile from QStringRef to QStringViewLars Knoll2020-06-121-3/+3
| | | | | | Task-number: QTBUG-84319 Change-Id: I7feb5c12eb5a8504c34292e0da75332b5ba9ef20 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Remove winrtOliver Wolff2020-06-061-176/+9
| | | | | | | | | Macros and the await helper function from qfunctions_winrt(_p).h are needed in other Qt modules which use UWP APIs on desktop windows. Task-number: QTBUG-84434 Change-Id: Ice09c11436ad151c17bdccd2c7defadd08c13925 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QFile::moveToTrash: work with relative file paths on WindowsVolker Hilsheimer2020-05-071-2/+2
| | | | | | | | | | | | | | | | | | | | The system APIs expect an absolute "display name" of the file path, so make it absolute. The test was overly tolerant in accepting failure, as a QStorageInfo initialized with a file path that doesn't exist is invalid, and thus always different from the QStorageInfo of the home directory. Fix the test to compare only valid QStorageInfo objects, and postpone the check until the file we want to move has been created. [ChangeLog][QtCore][QFile] moveToTrash supports relative file paths on Windows Change-Id: I94c8cd40c60fde469e38f76a98f867f20c6a0b15 Fixes: QTBUG-84015 Pick-to: 5.15 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Port qfilesystemengine_win.cpp to QRegularExpressionLars Knoll2020-04-151-5/+10
| | | | | | | QRegExp is going away in Qt 6. Change-Id: I282a444b9fdf1c834dcf90d7fd6743781b94643c Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Core: Use Qt::SplitBehavior in preference to QString::SplitBehaviorEdward Welbourne2020-02-281-1/+1
| | | | | | | | The Qt version was added in 5.14 "for use as eventual replacement for QString::SplitBehavior." Move another step closer to that goal. Change-Id: I446f9ddc8f8de4a0b79b09edb44f7c1496fbc33f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* On Windows 7, fall back to SHFileOperation to avoid confirmation dialogsVolker Hilsheimer2020-02-071-63/+69
| | | | | | | | | | | | | | | | | | | | Moving a file to the trash should preferably done via IFileOperation. However, the implementation on Windows 7 ignores the operation flags that request the shell not to show any confirmation dialogs or other UI elements. SHFileOperation is an old API that doesn't show any UI, but has the limitation that it doesn't report the location of the file in the trash after the move. So an application cannot restore the file, but the user can do so via Explorer. Overall, the better compromise is to not have dialogs at the expense of not being able to report the new path. This allows us to run the unit test on Windows 7 as well. Change-Id: Ib8e651a69e2c6750f668b52d2a70925d156cc8ae Fixes: QTBUG-81927 Reviewed-by: Vitaly Fanaskov <vitaly.fanaskov@qt.io>
* Implement moving of a single file system entry to the trashVolker Hilsheimer2020-01-301-0/+192
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements the operation for Windows, macOS, and Unix, for now only as a private API (since QFileSystemEngine is private). This adds the capability as a testable function; public API to be agreed on and added in a separate commit. The Unix implementation follows the freedesktop.org specification [1] version 1.0. [1] https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html On macOS and Windows, native APIs are used, with each having some limitations: * on macOS, the file in the trash won't have a "put back" option, as we don't use Finder automation, for the reasons provided in the comments * on Windows, we might not be able to use the modern IFileOperation API, e.g. if Qt is built with mingw which doesn't seem to provide the interface definition; the fallback doesn't provide access to the file name in the trash The test case creates files and directories, and moves them to the trash. As part of the cleanup routine, it deletes all file system entries created. If run on Windows without IFileOperations support, this will add a file in the trash for each test run, filling up hard drive space. Task-number: QTBUG-47703 Change-Id: I5f5f4e578be2f45d7da84f70a03acbe1a12a1231 Reviewed-by: Vitaly Fanaskov <vitaly.fanaskov@qt.io>
* QFileSystemEngine: Rework createDirectory on WindowsChristoph Schleifenbaum2019-10-251-54/+49
| | | | | | | | | | Try starting to create the directory at the end, not at the front. This is the same way as the Unix implementation is doing. This avoids problems like us trying to enter directories we are not allowed to read, which might be due to access rights or due to sandboxing. Change-Id: I67c1ed4bdc20a15b1af9b33aa48d59fea359da22 Reviewed-by: Christoph Schleifenbaum <christoph.schleifenbaum@kdab.com>
* QFileSystemEngine: Consistently check for invalid file namesUlf Hermann2019-10-241-1/+26
| | | | | | | | | | | | | | stat() and friends expect a null-terminated C string. There is no way to generate anything useful from a string that has null bytes in the middle. It's important to catch this early, as otherwise, for example, a QDir::exists() on such a path can return true, as the path is silently truncated. Extend the checks for empty file names to windows and add checks for null bytes. Change-Id: Ie9794c3a7c4fd57f9a66bdbbab8b45a08b6f9170 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>