martinzink commented on a change in pull request #1225:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1225#discussion_r768706698



##########
File path: extensions/sftp/processors/ListSFTP.cpp
##########
@@ -359,21 +360,21 @@ bool ListSFTP::filterFile(const std::string& parent_path, 
const std::string& fil
 
   /* Age */
   time_t now = time(nullptr);
-  uint64_t file_age = (now - attrs.mtime) * 1000;
+  std::chrono::milliseconds file_age = std::chrono::seconds(now - attrs.mtime);

Review comment:
       this wouldnt work because the rhs would be a `time_point<file_clock>` 
and not a `duration`, and afaik the attrs.mtime is measured from unix epoch and 
since the epoch of the file_clock is not necessarily the same as the unix 
epoch, the `time_point<file_clock>::time_since_epoch` could return something 
completely different from what we want.
   
   we could create a `time_point<file_clock>` from the attrs.mtime but for that 
we would need a platform specific helper function (because the file_clock 
interface is quite different on msvc, libc++ and on stdlibc++) it could be done 
with something similar to this (only in reverse):
   
https://github.com/rustammendel/nifi-minifi-cpp/pull/1/files#diff-796b46848475896d2982dcb681e0f547bac6aec3c98da80e8c03139562092604R89-R97
   
   or we could stick to using system_clock (which has the unix epoch)
   `auto file_age = std::chrono::system_clock::now() - 
std::chrono::system_clock::from_time_t(attrs.mtime);`
   




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