You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by bq...@apache.org on 2017/11/07 16:00:37 UTC
nifi-minifi-cpp git commit: MINIFICPP-292 Use portable method to
determine if path is a directory
Repository: nifi-minifi-cpp
Updated Branches:
refs/heads/master b9ec9b6a2 -> 0bdc00e67
MINIFICPP-292 Use portable method to determine if path is a directory
This closes #179.
Signed-off-by: Bin Qiu <be...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/commit/0bdc00e6
Tree: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/tree/0bdc00e6
Diff: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/diff/0bdc00e6
Branch: refs/heads/master
Commit: 0bdc00e6737ea8b835d7e4e54567f18d23a0c422
Parents: b9ec9b6
Author: Andrew I. Christianson <an...@andyic.org>
Authored: Sat Nov 4 17:01:08 2017 -0400
Committer: Bin Qiu <be...@gmail.com>
Committed: Tue Nov 7 07:59:14 2017 -0800
----------------------------------------------------------------------
libminifi/src/processors/GetFile.cpp | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/0bdc00e6/libminifi/src/processors/GetFile.cpp
----------------------------------------------------------------------
diff --git a/libminifi/src/processors/GetFile.cpp b/libminifi/src/processors/GetFile.cpp
index 1b73c2d..5676c23 100644
--- a/libminifi/src/processors/GetFile.cpp
+++ b/libminifi/src/processors/GetFile.cpp
@@ -254,17 +254,21 @@ void GetFile::performListing(std::string dir, const GetFileRequest &request) {
if (!entry)
break;
std::string d_name = entry->d_name;
- if ((entry->d_type & DT_DIR)) {
+ std::string path = dir + "/" + d_name;
+ struct stat statbuf{};
+ if (stat(path.c_str(), &statbuf) != 0) {
+ logger_->log_warn("Failed to stat %s", path);
+ break;
+ }
+ if (S_ISDIR(statbuf.st_mode)) {
// if this is a directory
if (request.recursive && strcmp(d_name.c_str(), "..") != 0 && strcmp(d_name.c_str(), ".") != 0) {
- std::string path = dir + "/" + d_name;
performListing(path, request);
}
} else {
- std::string fileName = dir + "/" + d_name;
- if (acceptFile(fileName, d_name, request)) {
+ if (acceptFile(path, d_name, request)) {
// check whether we can take this file
- putListing(fileName);
+ putListing(path);
}
}
}