phrocker commented on a change in pull request #558: MINIFICPP-542 - Add 
PutSFTP processor
URL: https://github.com/apache/nifi-minifi-cpp/pull/558#discussion_r285073100
 
 

 ##########
 File path: libminifi/include/utils/file/FileUtils.h
 ##########
 @@ -386,6 +415,141 @@ class FileUtils {
     FindClose(hFind);
 #endif
   }
+
+  static std::string concat_path(const std::string& root, const std::string& 
child) {
+    if (root.empty()) {
+      return child;
+    }
+    std::stringstream new_path;
+    if (root.back() == get_separator()) {
+      new_path << root << child;
+    } else {
+      new_path << root << get_separator() << child;
+    }
+    return new_path.str();
+  }
+
+  static std::string get_parent_path(const std::string& path) {
+    if (path.empty()) {
+      /* Empty path has no parent */
+      return "";
+    }
+    bool absolute = false;
+    size_t root_pos = 0U;
+#ifdef WIN32
+    if (path[0] == '\\') {
+      absolute = true;
+      if (path.size() < 2U) {
+        return "";
+      }
+      if (path[1] == '\\') {
+        if (path.size() >= 4U &&
+           (path[2] == '?' || path[2] == '.') &&
+            path[3] == '\\') {
+          /* Probably an UNC path */
+          root_pos = 4U;
+        } else {
+          /* Probably a \\server\-type path */
+          root_pos = 2U;
+        }
+        root_pos = path.find_first_of("\\", root_pos);
+        if (root_pos == std::string::npos) {
+          return "";
+        }
+      }
+    } else if (path.size() >= 3U &&
+               toupper(path[0]) >= 'A' &&
+               toupper(path[0]) <= 'Z' &&
+               path[1] == ':' &&
+               path[2] == '\\') {
+      absolute = true;
+      root_pos = 2U;
+    }
+#else
+    if (path[0] == '/') {
+      absolute = true;
+      root_pos = 0U;
+    }
+#endif
+    /* Ignore trailing separators */
+    size_t last_pos = path.size() - 1;
+    while (last_pos > root_pos && path[last_pos] == get_separator()) {
+      last_pos--;
+    }
+    if (absolute && last_pos == root_pos) {
+      /* This means we are only a root */
+      return "";
+    }
+    /* Find parent */
+    size_t last_separator = path.find_last_of(get_separator(), last_pos);
+    if (last_separator == std::string::npos || last_separator < root_pos) {
+      return "";
+    }
+    return path.substr(0, last_separator + 1);
+  }
+
+  /*
+   * Returns the absolute path of the current executable
+   */
+  static std::string get_executable_path() {
 
 Review comment:
   We should be using MINIFI_HOME instead of any system resources like this. 

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