martinzink commented on code in PR #1634:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1634#discussion_r1304323269
##########
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:
Afaik stat returns the last access and last modification time, but not the
creation time of the file.
It does also provide the last status change time but I am not sure if we
want to merge these concepts together.
--
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]