@@ -44,6 +44,11 @@ void writeFileSafe(const path &fn, const String &content, const path &lock_dir)
4444 write_file_if_different (fn, content);
4545}
4646
47+ static auto lwt_time_t (const path &fn) {
48+ auto lwt = std::chrono::clock_cast<std::chrono::system_clock>(fs::last_write_time (fn));
49+ return std::chrono::system_clock::to_time_t (lwt);
50+ }
51+
4752static bool should_patch (const path &fn, const path &hf, const path &hfn)
4853{
4954 static std::map<path, bool > to_patch;
@@ -58,10 +63,8 @@ static bool should_patch(const path &fn, const path &hf, const path &hfn)
5863 return to_patch[fn];
5964 }
6065 auto f = read_file (tsf);
61- fs::file_time_type::clock::duration d;
62- *(uint64_t *)&d = std::stoll (f);
63- fs::file_time_type::clock::time_point tp{d};
64- if (fs::last_write_time (fn) > tp) {
66+ time_t tp = std::stoll (f);
67+ if (lwt_time_t (fn) > tp) {
6568 return to_patch[fn] = true ;
6669 }
6770 return false ;
@@ -92,7 +95,7 @@ void replaceInFileOnce(const path &fn, const String &from, const String &to, con
9295 boost::replace_all (s, from, to);
9396 write_file (fn, s); // // if different?
9497 write_file_if_different (hfn, " " );
95- write_file (tsf, std::to_string (fs::last_write_time (fn). time_since_epoch (). count ( )));
98+ write_file (tsf, std::to_string (lwt_time_t (fn)));
9699}
97100
98101void pushFrontToFileOnce (const path &fn, const String &text, const path &lock_dir)
@@ -120,7 +123,7 @@ void pushFrontToFileOnce(const path &fn, const String &text, const path &lock_di
120123 s = text + " \n " + s;
121124 write_file (fn, s);
122125 write_file_if_different (hfn, " " );
123- write_file (tsf, std::to_string (fs::last_write_time (fn). time_since_epoch (). count ( )));
126+ write_file (tsf, std::to_string (lwt_time_t (fn)));
124127}
125128
126129void pushBackToFileOnce (const path &fn, const String &text, const path &lock_dir)
@@ -148,7 +151,7 @@ void pushBackToFileOnce(const path &fn, const String &text, const path &lock_dir
148151 s = s + " \n " + text;
149152 write_file (fn, s);
150153 write_file_if_different (hfn, " " );
151- write_file (tsf, std::to_string (fs::last_write_time (fn). time_since_epoch (). count ( )));
154+ write_file (tsf, std::to_string (lwt_time_t (fn)));
152155}
153156
154157bool patch (const path &fn, const String &patch, const path &lock_dir)
0 commit comments