arpadboda commented on a change in pull request #529: MINIFICPP-792 - TailFile 
processor should handle rotation of source file
URL: https://github.com/apache/nifi-minifi-cpp/pull/529#discussion_r271474813
 
 

 ##########
 File path: libminifi/src/processors/TailFile.cpp
 ##########
 @@ -179,58 +180,22 @@ void TailFile::checkRollOver(const std::string 
&fileLocation, const std::string
     std::size_t found = fileName.find_last_of(".");
     if (found != std::string::npos)
       pattern = fileName.substr(0, found);
-#ifndef WIN32
-    DIR *d;
-    d = opendir(fileLocation.c_str());
-    if (!d)
-      return;
-    while (1) {
-      struct dirent *entry;
-      entry = readdir(d);
-      if (!entry)
-        break;
-      std::string d_name = entry->d_name;
-      if (!(entry->d_type & DT_DIR)) {
-        std::string fileName = d_name;
-        std::string fileFullName = fileLocation + "/" + d_name;
-        if (fileFullName.find(pattern) != std::string::npos && 
stat(fileFullName.c_str(), &statbuf) == 0) {
-          if (((uint64_t) (statbuf.st_mtime) * 1000) >= 
modifiedTimeCurrentTailFile) {
-            TailMatchedFileItem item;
-            item.fileName = fileName;
-            item.modifiedTime = ((uint64_t) (statbuf.st_mtime) * 1000);
-            matchedFiles.push_back(item);
-          }
+
+    auto lambda = [&](const std::string& path, const std::string& filename) -> 
bool {
+      struct stat sb;
+      std::string fileFullName = path + 
utils::file::FileUtils::get_separator() + filename;
+      if (fileFullName.find(pattern) != std::string::npos && 
stat(fileFullName.c_str(), &sb) == 0) {
 
 Review comment:
   Done

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to