You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "fgerlits (via GitHub)" <gi...@apache.org> on 2023/05/04 09:41:27 UTC

[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1560: MINIFICPP-2101 Compilation fix in PutSFTPTests (libc++)

fgerlits commented on code in PR #1560:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1560#discussion_r1184786953


##########
libminifi/src/utils/file/FileUtils.cpp:
##########
@@ -66,21 +66,21 @@ bool contains(const std::filesystem::path& file_path, std::string_view text_to_s
   return std::search(view.begin(), view.end(), searcher) != view.end();
 }
 
-time_t to_time_t(std::filesystem::file_time_type file_time) {
-#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 14000
-  return std::chrono::file_clock::to_time_t(file_time);
+std::chrono::system_clock::time_point to_sys(std::filesystem::file_time_type file_time) {
+  using namespace std::chrono;  // NOLINT(build/namespaces)
+#if defined(WIN32) || (defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION < 14000))
+  return system_clock::now() + duration_cast<system_clock::duration>(file_time - file_clock::now());

Review Comment:
   I think this causes occasional unit test failures because we read `now()` twice, and sometimes we get two different ticks back.
   
   As an alternative, this worked for me on Windows:
   ```c++
     // to_sys
     return utc_clock::to_sys(file_clock::to_utc(file_time));
   
     // from_sys
     return file_clock::from_utc(utc_clock::from_sys(sys_time));
   ```
   
   I'm not sure if it works on libc++ version < 14, too, but I'm also not sure if we really need to support libc++ version < 14.



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org