martinzink commented on code in PR #1634:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1634#discussion_r1322631868


##########
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};
+}
+
+nonstd::expected<WindowsFileTimes, std::error_code> getWindowsFileTimes(const 
std::filesystem::path& path) {
+  WIN32_FILE_ATTRIBUTE_DATA file_attributes;
+  auto get_file_attributes_result = GetFileAttributesExW(path.c_str(), 
GetFileExInfoStandard, &file_attributes);
+  if (!get_file_attributes_result)
+    return 
nonstd::make_unexpected(utils::OsUtils::windowsErrorToErrorCode(GetLastError()));
+  return WindowsFileTimes{.creation_time = 
fileTimePointFromFileTime(file_attributes.ftCreationTime),
+                          .last_access_time = 
fileTimePointFromFileTime(file_attributes.ftLastAccessTime),
+                          .last_write_time = 
fileTimePointFromFileTime(file_attributes.ftLastWriteTime)};
+}

Review Comment:
   I've tried to implement your suggestion (fortunetly macos also has the 
creation time concept), but on centos 7 statx is still missing (it needs kernel 
4.11 and glibc 2.28), and centos7 uses 2.17 glibc.
   And our alpine based docker build also fails due to statx not being exposed 
through musl :(



-- 
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]

Reply via email to