summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/disk_interface.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/disk_interface.cc b/src/disk_interface.cc
index 50a2d97..fa0aa3d 100644
--- a/src/disk_interface.cc
+++ b/src/disk_interface.cc
@@ -82,12 +82,23 @@ TimeStamp StatSingleFile(const string& path, bool quiet) {
return TimeStampFromFileTime(attrs.ftLastWriteTime);
}
+bool IsWindows7OrLater() {
+ OSVERSIONINFO version_info = { sizeof(version_info) };
+ if (!GetVersionEx(&version_info))
+ Fatal("GetVersionEx: %s", GetLastErrorString().c_str());
+ return version_info.dwMajorVersion > 6 ||
+ version_info.dwMajorVersion == 6 && version_info.dwMinorVersion >= 1;
+}
+
bool StatAllFilesInDir(const string& dir, map<string, TimeStamp>* stamps,
bool quiet) {
// FindExInfoBasic is 30% faster than FindExInfoStandard.
+ static bool can_use_basic_info = IsWindows7OrLater();
+ FINDEX_INFO_LEVELS level =
+ can_use_basic_info ? FindExInfoBasic : FindExInfoStandard;
WIN32_FIND_DATAA ffd;
- HANDLE find_handle = FindFirstFileExA((dir + "\\*").c_str(), FindExInfoBasic,
- &ffd, FindExSearchNameMatch, NULL, 0);
+ HANDLE find_handle = FindFirstFileExA((dir + "\\*").c_str(), level, &ffd,
+ FindExSearchNameMatch, NULL, 0);
if (find_handle == INVALID_HANDLE_VALUE) {
DWORD err = GetLastError();