io: Remove version checks for versions below Win 10

It's not supported.

Change-Id: Ia17fc7e1d5ae785eca0a6ba530f9b9bc960605d4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Mårten Nordheim 2021-07-15 17:19:43 +02:00
parent c877e9760b
commit 6a51ff3f0d
3 changed files with 36 additions and 76 deletions

View File

@ -694,8 +694,7 @@ QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry)
//static //static
QByteArray QFileSystemEngine::id(HANDLE fHandle) QByteArray QFileSystemEngine::id(HANDLE fHandle)
{ {
return QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows8 ? return fileIdWin8(HANDLE(fHandle));
fileIdWin8(HANDLE(fHandle)) : fileId(HANDLE(fHandle));
} }
//static //static
@ -1420,12 +1419,6 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source,
// we need the "display name" of the file, so can't use nativeAbsoluteFilePath // we need the "display name" of the file, so can't use nativeAbsoluteFilePath
const QString sourcePath = QDir::toNativeSeparators(absoluteName(source).filePath()); 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__) # if defined(__IFileOperation_INTERFACE_DEFINED__)
CoInitialize(NULL); CoInitialize(NULL);
IFileOperation *pfo = nullptr; IFileOperation *pfo = nullptr;
@ -1464,35 +1457,6 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source,
newLocation = QFileSystemEntry(sink->targetPath); newLocation = QFileSystemEntry(sink->targetPath);
# endif // no IFileOperation in SDK (mingw, likely) - fall back to SHFileOperation # 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; return true;
} }

View File

@ -89,10 +89,8 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa
haveData = true; haveData = true;
int infoLevel = 0 ; // FindExInfoStandard; int infoLevel = 0 ; // FindExInfoStandard;
DWORD dwAdditionalFlags = 0; DWORD dwAdditionalFlags = 0;
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows7) {
dwAdditionalFlags = 2; // FIND_FIRST_EX_LARGE_FETCH dwAdditionalFlags = 2; // FIND_FIRST_EX_LARGE_FETCH
infoLevel = 1 ; // FindExInfoBasic; infoLevel = 1 ; // FindExInfoBasic;
}
int searchOps = 0; // FindExSearchNameMatch int searchOps = 0; // FindExSearchNameMatch
if (onlyDirs) if (onlyDirs)
searchOps = 1 ; // FindExSearchLimitToDirectories searchOps = 1 ; // FindExSearchLimitToDirectories

View File

@ -100,8 +100,6 @@ static bool isProcessLowIntegrity() {
// Disable function until Qt CI is updated // Disable function until Qt CI is updated
return false; return false;
#else #else
if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows8)
return false;
// non-leaking pseudo-handle. Expanded inline function GetCurrentProcessToken() // non-leaking pseudo-handle. Expanded inline function GetCurrentProcessToken()
// (was made an inline function in Windows 8). // (was made an inline function in Windows 8).
const auto process_token = HANDLE(quintptr(-4)); const auto process_token = HANDLE(quintptr(-4));