From fe37b48dffd8edcd6e30f4e304d3e27a731ac8ae Mon Sep 17 00:00:00 2001 From: Tannin Date: Sat, 29 Jun 2013 18:04:10 +0200 Subject: - caching of downloadwidgets to fix performance problem, currently broken and disabled - added new state for downloads "uninstalled" for mods that were at one point installed and then removed - user-configured server preference is now used - updated tutorial to account for removal of integrated browser - reverted to qt 4 - using performance optimised findfirstfile on win vista and up - bugfix: it was possible to disable all columns of the mod list - bugfix: hook.dll doesn't load on win xp --- src/shared/directoryentry.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/shared') diff --git a/src/shared/directoryentry.cpp b/src/shared/directoryentry.cpp index 9958b934..5f0e0b5a 100644 --- a/src/shared/directoryentry.cpp +++ b/src/shared/directoryentry.cpp @@ -421,12 +421,33 @@ void DirectoryEntry::addFromBSA(const std::wstring &originName, std::wstring &di } +static bool SupportOptimizedFind() +{ + OSVERSIONINFO versionInfo; + versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&versionInfo); + + // large fetch and basic info for FindFirstFileEx is supported on win server 2008 r2, win 7 and newer + return (versionInfo.dwMajorVersion > 6) || + ((versionInfo.dwMajorVersion == 6) && (versionInfo.dwMinorVersion >= 1)); +} + + void DirectoryEntry::addFiles(FilesOrigin &origin, wchar_t *buffer, int bufferOffset) { WIN32_FIND_DATAW findData; _snwprintf(buffer + bufferOffset, MAXPATH_UNICODE - bufferOffset, L"\\*"); - HANDLE searchHandle = ::FindFirstFileExW(buffer, FindExInfoStandard, &findData, FindExSearchNameMatch, NULL, FIND_FIRST_EX_CASE_SENSITIVE); + + HANDLE searchHandle = NULL; + + if (SupportOptimizedFind()) { + searchHandle = ::FindFirstFileExW(buffer, FindExInfoBasic, &findData, FindExSearchNameMatch, NULL, + FIND_FIRST_EX_LARGE_FETCH); + } else { + searchHandle = ::FindFirstFileExW(buffer, FindExInfoStandard, &findData, FindExSearchNameMatch, NULL, 0); + } + if (searchHandle != INVALID_HANDLE_VALUE) { BOOL result = true; while (result) { -- cgit v1.3.1