You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/02/24 16:31:19 UTC

[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1015: MINIFICPP-1509 - Use _stat64 on windows to handle large files

lordgamez commented on a change in pull request #1015:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1015#discussion_r582102407



##########
File path: extensions/standard-processors/processors/GetFile.cpp
##########
@@ -228,42 +228,48 @@ void GetFile::pollListing(std::queue<std::string> &list, const GetFileRequest &r
 bool GetFile::acceptFile(std::string fullName, std::string name, const GetFileRequest &request) {
   logger_->log_trace("Checking file: %s", fullName);
 
+#ifdef WIN32
+  struct _stat64 statbuf;
+  if (_stat64(fullName.c_str(), &statbuf) != 0) {
+    return false;
+  }
+#else
   struct stat statbuf;
+  if (stat(fullName.c_str(), &statbuf) != 0) {
+    return false;
+  }
+#endif
 
-  if (stat(fullName.c_str(), &statbuf) == 0) {
-    if (request.minSize > 0 && statbuf.st_size < (int32_t) request.minSize)
-      return false;
-
-    if (request.maxSize > 0 && statbuf.st_size > (int32_t) request.maxSize)
-      return false;
+  if (request.minSize > 0 && statbuf.st_size < request.minSize)

Review comment:
       Wouldn't removing the casts introduce sign-compare warnings?

##########
File path: libminifi/include/utils/file/FileUtils.h
##########
@@ -334,20 +332,28 @@ inline bool get_uid_gid(const std::string &path, uint64_t &uid, uint64_t &gid) {
 #endif
 
 inline bool is_directory(const char * path) {
+#ifndef WIN32
   struct stat dir_stat;
-  if (stat(path, &dir_stat) < 0) {
+  if (stat(path, &dir_stat) != 0) {
       return false;
   }
   return S_ISDIR(dir_stat.st_mode) != 0;
+#else
+  struct _stat64 dir_stat;
+  if (_stat64(path, &dir_stat) != 0) {
+      return false;
+  }
+  return S_ISDIR(dir_stat.st_mode) != 0;
+#endif
 }
 
 inline bool exists(const std::string& path) {
 #ifdef USE_BOOST
   return boost::filesystem::exists(path);
 #else
 #ifdef WIN32

Review comment:
       You could merge these as well, like you did in `last_write_time`




----------------------------------------------------------------
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:
users@infra.apache.org