fgerlits commented on a change in pull request #1283:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1283#discussion_r839541031
##########
File path: libminifi/include/utils/file/FileUtils.h
##########
@@ -171,6 +179,19 @@ inline const
std::optional<std::filesystem::file_time_type> last_write_time(cons
return std::nullopt;
}
+inline std::optional<std::string>
get_last_modified_time_formatted_string(const std::string& path, const
std::string& format_string) {
+ auto last_write = last_write_time(path);
+ if (!last_write) {
+ return std::nullopt;
+ }
+ auto last_write_time_t = to_time_t(*last_write);
+ std::array<char, 128U> result;
+ if (std::strftime(result.data(), result.size(), format_string.c_str(),
gmtime(&last_write_time_t)) != 0) {
+ return std::string(result.data());
+ }
+ return std::nullopt;
Review comment:
I didn't realize this was a `file_time_type`, not a
`time_point<system_clock>`. Since this is file-related, it's OK to keep it in
FileUtils; but I would still move the time formatting code to a separate
`format_file_time()` function.
--
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]