summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2021-07-15 17:19:43 +0200
committerMårten Nordheim <marten.nordheim@qt.io>2021-07-28 13:18:50 +0200
commit6a51ff3f0d6ca6b268825b60c95ddcf972bb4d49 (patch)
treefb7a900f7378db90d0fd68966c8415f11d9b9aea /src/corelib/io
parentc877e9760bfe6b1493140a2f861232e0ab43d273 (diff)
io: Remove version checks for versions below Win 10
It's not supported. Change-Id: Ia17fc7e1d5ae785eca0a6ba530f9b9bc960605d4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp106
-rw-r--r--src/corelib/io/qfilesystemiterator_win.cpp6
-rw-r--r--src/corelib/io/qstandardpaths_win.cpp2
3 files changed, 37 insertions, 77 deletions
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index b2e1870b3d..075ce0ffac 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -694,8 +694,7 @@ QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry)
//static
QByteArray QFileSystemEngine::id(HANDLE fHandle)
{
- return QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows8 ?
- fileIdWin8(HANDLE(fHandle)) : fileId(HANDLE(fHandle));
+ return fileIdWin8(HANDLE(fHandle));
}
//static
@@ -1420,79 +1419,44 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source,
// we need the "display name" of the file, so can't use nativeAbsoluteFilePath
const QString sourcePath = QDir::toNativeSeparators(absoluteName(source).filePath());
- /*
- Windows 7 insists on showing confirmation dialogs and ignores the respective
- flags set on IFileOperation. Fall back to SHFileOperation, even if it doesn't
- give us the new location of the file.
- */
- if (QOperatingSystemVersion::current() > QOperatingSystemVersion::Windows7) {
# if defined(__IFileOperation_INTERFACE_DEFINED__)
- CoInitialize(NULL);
- IFileOperation *pfo = nullptr;
- IShellItem *deleteItem = nullptr;
- FileOperationProgressSink *sink = nullptr;
- HRESULT hres = E_FAIL;
-
- auto coUninitialize = qScopeGuard([&](){
- if (sink)
- sink->Release();
- if (deleteItem)
- deleteItem->Release();
- if (pfo)
- pfo->Release();
- CoUninitialize();
- if (!SUCCEEDED(hres))
- error = QSystemError(hres, QSystemError::NativeError);
- });
-
- hres = CoCreateInstance(CLSID_FileOperation, nullptr, CLSCTX_ALL, IID_PPV_ARGS(&pfo));
- if (!pfo)
- return false;
- pfo->SetOperationFlags(FOF_ALLOWUNDO | FOFX_RECYCLEONDELETE | FOF_NOCONFIRMATION
- | FOF_SILENT | FOF_NOERRORUI);
- hres = SHCreateItemFromParsingName(reinterpret_cast<const wchar_t*>(sourcePath.utf16()),
- nullptr, IID_PPV_ARGS(&deleteItem));
- if (!deleteItem)
- return false;
- sink = new FileOperationProgressSink;
- hres = pfo->DeleteItem(deleteItem, static_cast<IFileOperationProgressSink*>(sink));
- if (!SUCCEEDED(hres))
- return false;
- hres = pfo->PerformOperations();
+ CoInitialize(NULL);
+ IFileOperation *pfo = nullptr;
+ IShellItem *deleteItem = nullptr;
+ FileOperationProgressSink *sink = nullptr;
+ HRESULT hres = E_FAIL;
+
+ auto coUninitialize = qScopeGuard([&](){
+ if (sink)
+ sink->Release();
+ if (deleteItem)
+ deleteItem->Release();
+ if (pfo)
+ pfo->Release();
+ CoUninitialize();
if (!SUCCEEDED(hres))
- return false;
- newLocation = QFileSystemEntry(sink->targetPath);
+ error = QSystemError(hres, QSystemError::NativeError);
+ });
+
+ hres = CoCreateInstance(CLSID_FileOperation, nullptr, CLSCTX_ALL, IID_PPV_ARGS(&pfo));
+ if (!pfo)
+ return false;
+ pfo->SetOperationFlags(FOF_ALLOWUNDO | FOFX_RECYCLEONDELETE | FOF_NOCONFIRMATION
+ | FOF_SILENT | FOF_NOERRORUI);
+ hres = SHCreateItemFromParsingName(reinterpret_cast<const wchar_t*>(sourcePath.utf16()),
+ nullptr, IID_PPV_ARGS(&deleteItem));
+ if (!deleteItem)
+ return false;
+ sink = new FileOperationProgressSink;
+ hres = pfo->DeleteItem(deleteItem, static_cast<IFileOperationProgressSink*>(sink));
+ if (!SUCCEEDED(hres))
+ return false;
+ hres = pfo->PerformOperations();
+ if (!SUCCEEDED(hres))
+ return false;
+ newLocation = QFileSystemEntry(sink->targetPath);
# endif // no IFileOperation in SDK (mingw, likely) - fall back to SHFileOperation
- } else {
- // double null termination needed, so can't use QString::utf16
- QVarLengthArray<wchar_t, MAX_PATH + 1> winFile(sourcePath.length() + 2);
- sourcePath.toWCharArray(winFile.data());
- winFile[sourcePath.length()] = wchar_t{};
- winFile[sourcePath.length() + 1] = wchar_t{};
-
- SHFILEOPSTRUCTW operation;
- operation.hwnd = nullptr;
- operation.wFunc = FO_DELETE;
- operation.pFrom = winFile.constData();
- operation.pTo = nullptr;
- operation.fFlags = FOF_ALLOWUNDO | FOF_NO_UI;
- operation.fAnyOperationsAborted = FALSE;
- operation.hNameMappings = nullptr;
- operation.lpszProgressTitle = nullptr;
-
- int result = SHFileOperation(&operation);
- if (result != 0) {
- error = QSystemError(result, QSystemError::NativeError);
- return false;
- }
- /*
- This implementation doesn't let us know where the file ended up, even if
- we would specify FOF_WANTMAPPINGHANDLE | FOF_RENAMEONCOLLISION, as
- FOF_RENAMEONCOLLISION has no effect unless files are moved, copied, or renamed.
- */
- Q_UNUSED(newLocation);
- }
return true;
}
diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp
index ca9f83c0ab..1b65ae3c09 100644
--- a/src/corelib/io/qfilesystemiterator_win.cpp
+++ b/src/corelib/io/qfilesystemiterator_win.cpp
@@ -89,10 +89,8 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa
haveData = true;
int infoLevel = 0 ; // FindExInfoStandard;
DWORD dwAdditionalFlags = 0;
- if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows7) {
- dwAdditionalFlags = 2; // FIND_FIRST_EX_LARGE_FETCH
- infoLevel = 1 ; // FindExInfoBasic;
- }
+ dwAdditionalFlags = 2; // FIND_FIRST_EX_LARGE_FETCH
+ infoLevel = 1 ; // FindExInfoBasic;
int searchOps = 0; // FindExSearchNameMatch
if (onlyDirs)
searchOps = 1 ; // FindExSearchLimitToDirectories
diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp
index eb0ed58bcb..e619687a8b 100644
--- a/src/corelib/io/qstandardpaths_win.cpp
+++ b/src/corelib/io/qstandardpaths_win.cpp
@@ -100,8 +100,6 @@ static bool isProcessLowIntegrity() {
// Disable function until Qt CI is updated
return false;
#else
- if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows8)
- return false;
// non-leaking pseudo-handle. Expanded inline function GetCurrentProcessToken()
// (was made an inline function in Windows 8).
const auto process_token = HANDLE(quintptr(-4));