martinzink commented on code in PR #1634:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1634#discussion_r1304331953
##########
libminifi/src/utils/file/FileUtils.cpp:
##########
@@ -96,4 +100,22 @@ std::filesystem::file_time_type
from_sys(std::chrono::system_clock::time_point s
#endif
}
+#ifdef WIN32
+std::chrono::file_clock::time_point fileTimePointFromFileTime(const FILETIME&
filetime) {
+ static_assert(std::ratio_equal_v<std::chrono::file_clock::duration::period,
std::ratio<1, 10000000>>, "file_clock duration must be 100 nanoseconds");
+ std::chrono::file_clock::duration
duration{(static_cast<int64_t>(filetime.dwHighDateTime) << 32) |
filetime.dwLowDateTime};
+ return std::chrono::file_clock::time_point{duration};
Review Comment:
I would rather keep the static assert and rely on the file_clock duration as
it (in my opinion) helps to convey the message that the FILETIME and file_clock
(on windows at least) are basically the same thing. (same epoch, same period).
I've added a comment and some tests that will notify us in the unlikely event
that microsoft changes either the FILETIME or the file_clock epoch/period in
https://github.com/apache/nifi-minifi-cpp/pull/1634/commits/43fa98b93ee866a89b44740a7ff29d18e3e551d7#diff-796b46848475896d2982dcb681e0f547bac6aec3c98da80e8c03139562092604R105
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]