#define VER_LAMEXP_MINOR_LO 4
#define VER_LAMEXP_TYPE Beta
#define VER_LAMEXP_PATCH 11
-#define VER_LAMEXP_BUILD 942
+#define VER_LAMEXP_BUILD 944
///////////////////////////////////////////////////////////////////////////////
// Tool versions (minimum expected versions!)
#define LAMEXP_DELETE_ARRAY(PTR) if(PTR) { delete [] PTR; PTR = NULL; }
#define LAMEXP_SAFE_FREE(PTR) if(PTR) { free((void*) PTR); PTR = NULL; }
#define LAMEXP_CLOSE(HANDLE) if(HANDLE != NULL && HANDLE != INVALID_HANDLE_VALUE) { CloseHandle(HANDLE); HANDLE = NULL; }
+#define LAMEXP_MIN_OS_VER(VER_INFO, VER_MAJ, VER_MIN) ((HIWORD(VER_INFO) > (VER_MAJ)) || ((HIWORD(VER_INFO) == (VER_MAJ)) && (LOWORD(VER_INFO) >= (VER_MIN))))
#define QWCHAR(STR) reinterpret_cast<const wchar_t*>(STR.utf16())
#define WCHAR2QSTR(STR) QString::fromUtf16(reinterpret_cast<const unsigned short*>(STR))
#define LAMEXP_DYNCAST(OUT,CLASS,SRC) try { OUT = dynamic_cast<CLASS>(SRC); } catch(std::bad_cast) { OUT = NULL; }
QHash<const QString, bool> QFileSystemModelEx::s_hasSubfolderCache;
QMutex QFileSystemModelEx::s_hasSubfolderMutex;
+void *QFileSystemModelEx::FindFirstFileExPtr = NULL;
+bool QFileSystemModelEx::FindFirstFileExInitialized = false;
+bool QFileSystemModelEx::FindFirstFileExInfoBasicOK = false;
+
bool QFileSystemModelEx::hasSubfoldersCached(const QString &path)
{
QMutexLocker lock(&s_hasSubfolderMutex);
bool QFileSystemModelEx::hasSubfolders(const QString &path)
{
- static bool FindFirstFileExInitialized = false;
- static FindFirstFileExFun FindFirstFileExPtr = NULL;
-
if(!FindFirstFileExInitialized)
{
QLibrary Kernel32Lib("kernel32.dll");
- FindFirstFileExPtr = (FindFirstFileExFun) Kernel32Lib.resolve("FindFirstFileExW");
+ FindFirstFileExPtr = Kernel32Lib.resolve("FindFirstFileExW");
+ DWORD osVersionNo = lamexp_get_os_version();
+ FindFirstFileExInfoBasicOK = LAMEXP_MIN_OS_VER(osVersionNo, 6, 1);
FindFirstFileExInitialized = true;
}
-
+
WIN32_FIND_DATAW findData;
bool bChildren = false;
HANDLE h = (FindFirstFileExPtr)
- ? FindFirstFileExPtr(QWCHAR(QDir::toNativeSeparators(path + "/*")), FindExInfoStandard, &findData, FindExSearchLimitToDirectories, NULL, 0)
+ ? reinterpret_cast<FindFirstFileExFun>(FindFirstFileExPtr)(QWCHAR(QDir::toNativeSeparators(path + "/*")), (FindFirstFileExInfoBasicOK ? FindExInfoBasic : FindExInfoStandard), &findData, FindExSearchLimitToDirectories, NULL, 0)
: FindFirstFileW(QWCHAR(QDir::toNativeSeparators(path + "/*")), &findData);
-
+
if(h != INVALID_HANDLE_VALUE)
{
if(NO_DOT_OR_DOTDOT(findData.cFileName))
}
FindClose(h);
}
+ else
+ {
+ DWORD err = GetLastError();
+ if((err == ERROR_NOT_SUPPORTED) || (err == ERROR_INVALID_PARAMETER))
+ {
+ qWarning("%s failed with error code #%u", FindFirstFileExPtr ? "FindFirstFileEx" : "FindFirstFile", err);
+ }
+ }
+
return bChildren;
}
static QHash<const QString, bool> s_hasSubfolderCache;
static QMutex s_hasSubfolderMutex;
+ static void *FindFirstFileExPtr;
+ static bool FindFirstFileExInitialized;
+ static bool FindFirstFileExInfoBasicOK;
+
static bool hasSubfolders(const QString &path);
static bool hasSubfoldersCached(const QString &path);
static void removeFromCache(const QString &path);