From d34f88080c8cf2bb0c850dab5911a835eb80cc8d Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 8 Feb 2013 09:02:30 -0800 Subject: [PATCH] Fix directory iteration on Windows XP --- aegisub/libaegisub/windows/fs.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/aegisub/libaegisub/windows/fs.cpp b/aegisub/libaegisub/windows/fs.cpp index b075775e5..57c29d10f 100644 --- a/aegisub/libaegisub/windows/fs.cpp +++ b/aegisub/libaegisub/windows/fs.cpp @@ -32,6 +32,20 @@ namespace bfs = boost::filesystem; #undef CreateDirectory +namespace { + FINDEX_INFO_LEVELS find_info_level() { + OSVERSIONINFO osvi; + ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&osvi); + + if (osvi.dwMajorVersion > 6 || (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion >= 1)) + return FindExInfoBasic; + else + return FindExInfoStandard; + } +} + namespace agi { namespace fs { std::string ShortName(path const& p) { std::wstring out(MAX_PATH + 1, 0); @@ -68,7 +82,7 @@ DirectoryIterator::DirectoryIterator(path const& p, std::string const& filter) : privdata(new PrivData) { WIN32_FIND_DATA data; - privdata->h = FindFirstFileEx((p/(filter.empty() ? "*.*" : filter)).c_str(), FindExInfoBasic, &data, FindExSearchNameMatch, nullptr, 0); + privdata->h = FindFirstFileEx((p/(filter.empty() ? "*.*" : filter)).c_str(), find_info_level(), &data, FindExSearchNameMatch, nullptr, 0); if (privdata->h == INVALID_HANDLE_VALUE) { privdata.reset(); return;