-
Notifications
You must be signed in to change notification settings - Fork 561
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kavyasree
committed
Dec 27, 2024
1 parent
4141b76
commit 0a897ff
Showing
2 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
From 70a3386b744d3c3289c5c726efa2cd19b0736880 Mon Sep 17 00:00:00 2001 | ||
From: kavyasree <[email protected]> | ||
Date: Fri, 27 Dec 2024 11:04:33 +0530 | ||
Subject: [PATCH] Fix-bazel-build | ||
|
||
--- | ||
file_windows.cc | 53 ++++++++++++++++--- | ||
1 file changed, 45 insertions(+), 8 deletions(-) | ||
|
||
diff --git a/file_windows.cc b/file_windows.cc | ||
index 5798ffacf..9c45e9260 100755 | ||
--- a/file_windows.cc | ||
+++ b/file_windows.cc | ||
@@ -118,16 +118,56 @@ class WindowsFileMtime : public IFileMtime { | ||
bool SetToDistantFuture(const Path& path) override; | ||
|
||
private: | ||
+ // 1 year in FILETIME. | ||
+ static const ULARGE_INTEGER kOneYear; | ||
// 9 years in the future. | ||
const FILETIME near_future_; | ||
// 10 years in the future. | ||
const FILETIME distant_future_; | ||
|
||
- static FILETIME GetNow(); | ||
- static FILETIME GetFuture(WORD years); | ||
+ static ULARGE_INTEGER&& OneYearDelay(); | ||
+ static const FILETIME GetNow(); | ||
+ static const FILETIME GetFuture(WORD years); | ||
static bool Set(const Path& path, FILETIME time); | ||
}; | ||
|
||
+const ULARGE_INTEGER WindowsFileMtime::kOneYear = | ||
+ std::move(WindowsFileMtime::OneYearDelay()); | ||
+ULARGE_INTEGER&& WindowsFileMtime::OneYearDelay() { | ||
+ SYSTEMTIME now; | ||
+ GetSystemTime(&now); | ||
+ now.wMonth = 1; | ||
+ now.wDayOfWeek = 0; | ||
+ now.wDay = 1; | ||
+ now.wHour = 0; | ||
+ now.wMinute = 0; | ||
+ now.wSecond = 0; | ||
+ now.wMilliseconds = 0; | ||
+ FILETIME now_ft; | ||
+ if (!::SystemTimeToFileTime(&now, &now_ft)) { | ||
+ string err = GetLastErrorString(); | ||
+ BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR) | ||
+ << "WindowsFileMtime::OneYearDelay: SystemTimeToFileTime 1 failed: " | ||
+ << err; | ||
+ } | ||
+ ULARGE_INTEGER t1; | ||
+ t1.LowPart = now_ft.dwLowDateTime; | ||
+ t1.HighPart = now_ft.dwHighDateTime; | ||
+ now.wYear++; | ||
+ if (!::SystemTimeToFileTime(&now, &now_ft)) { | ||
+ string err = GetLastErrorString(); | ||
+ BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR) | ||
+ << "WindowsFileMtime::OneYearDelay: SystemTimeToFileTime 2 failed: " | ||
+ << err; | ||
+ } | ||
+ ULARGE_INTEGER t2; | ||
+ t2.LowPart = now_ft.dwLowDateTime; | ||
+ t2.HighPart = now_ft.dwHighDateTime; | ||
+ t2.QuadPart -= t1.QuadPart; | ||
+ return std::move(t2); | ||
+} | ||
+ | ||
+ | ||
bool WindowsFileMtime::IsUntampered(const Path& path) { | ||
if (path.IsEmpty() || path.IsNull()) { | ||
return false; | ||
@@ -205,23 +245,20 @@ bool WindowsFileMtime::Set(const Path& path, FILETIME time) { | ||
/* lpLastWriteTime */ &time) == TRUE; | ||
} | ||
|
||
-FILETIME WindowsFileMtime::GetNow() { | ||
+const FILETIME WindowsFileMtime::GetNow() { | ||
FILETIME now; | ||
GetSystemTimeAsFileTime(&now); | ||
return now; | ||
} | ||
|
||
-FILETIME WindowsFileMtime::GetFuture(WORD years) { | ||
+const FILETIME WindowsFileMtime::GetFuture(WORD years) { | ||
FILETIME result; | ||
GetSystemTimeAsFileTime(&result); | ||
|
||
- // 1 year in FILETIME. | ||
- constexpr ULONGLONG kOneYear = 365ULL * 24 * 60 * 60 * 10'000'000; | ||
- | ||
ULARGE_INTEGER result_value; | ||
result_value.LowPart = result.dwLowDateTime; | ||
result_value.HighPart = result.dwHighDateTime; | ||
- result_value.QuadPart += kOneYear * years; | ||
+ result_value.QuadPart += kOneYear.QuadPart * years; | ||
result.dwLowDateTime = result_value.LowPart; | ||
result.dwHighDateTime = result_value.HighPart; | ||
return result; | ||
-- | ||
2.34.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters