This is an automated email from the ASF dual-hosted git repository.

fgerlits pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git

commit bd3d818b13b7102989e2eeb5fb179e9bf68940eb
Author: Martin Zink <[email protected]>
AuthorDate: Thu Dec 8 15:15:54 2022 +0100

    MINIFICPP-2000 Fixing GetFile's inconsistent attributes
    
    Signed-off-by: Ferenc Gerlits <[email protected]>
    This closes #1476
---
 extensions/http-curl/tests/C2DebugBundleTest.cpp   |  2 +-
 .../http-curl/tests/C2PropertiesUpdateTests.cpp    |  2 +-
 extensions/script/tests/PythonManifestTests.cpp    |  2 +-
 .../standard-processors/processors/GetFile.cpp     | 24 +++++-------
 .../standard-processors/processors/GetFile.h       |  2 +-
 .../standard-processors/processors/ListFile.cpp    |  1 -
 .../tests/unit/AttributesToJSONTests.cpp           | 20 +++++-----
 .../tests/unit/GetFileTests.cpp                    | 44 +++++++++++++++++-----
 .../tests/unit/ListFileTests.cpp                   | 30 +++++++++++++++
 .../tests/unit/ProcessorTests.cpp                  | 12 +++---
 .../tests/unit/PutFileTests.cpp                    | 34 ++++++-----------
 .../tests/unit/TailFileTests.cpp                   |  2 +-
 libminifi/src/c2/C2Agent.cpp                       |  2 +-
 libminifi/test/unit/FilePatternTests.cpp           | 10 ++---
 libminifi/test/unit/FileUtilsTests.cpp             |  6 +--
 15 files changed, 115 insertions(+), 78 deletions(-)

diff --git a/extensions/http-curl/tests/C2DebugBundleTest.cpp 
b/extensions/http-curl/tests/C2DebugBundleTest.cpp
index 1119770bb..6001b3f99 100644
--- a/extensions/http-curl/tests/C2DebugBundleTest.cpp
+++ b/extensions/http-curl/tests/C2DebugBundleTest.cpp
@@ -146,7 +146,7 @@ int main() {
   C2DebugBundleHandler bundle_handler;
 
   std::filesystem::path home_dir = controller.createTempDirectory();
-  utils::file::PathUtils::create_dir((home_dir / "conf").string());
+  utils::file::PathUtils::create_dir(home_dir / "conf");
   std::ofstream{home_dir / "conf/minifi.properties", std::ios::binary} << 
properties_file;
   std::ofstream{home_dir / "conf/config.yml", std::ios::binary} << 
flow_config_file;
 
diff --git a/extensions/http-curl/tests/C2PropertiesUpdateTests.cpp 
b/extensions/http-curl/tests/C2PropertiesUpdateTests.cpp
index f06c8d9a4..a4f742147 100644
--- a/extensions/http-curl/tests/C2PropertiesUpdateTests.cpp
+++ b/extensions/http-curl/tests/C2PropertiesUpdateTests.cpp
@@ -128,7 +128,7 @@ int main() {
 
   std::filesystem::path home_dir = tmp_dir.getPath();
 
-  utils::file::PathUtils::create_dir((home_dir / "conf").string());
+  utils::file::PathUtils::create_dir(home_dir / "conf");
   std::ofstream{home_dir / "conf/minifi.properties"} << properties_file;
   std::ofstream{home_dir / "conf/minifi-log.properties"} << 
log_properties_file;
   std::ofstream{home_dir / "conf/config.yml"} << empty_flow;
diff --git a/extensions/script/tests/PythonManifestTests.cpp 
b/extensions/script/tests/PythonManifestTests.cpp
index 9b0db0237..168201985 100644
--- a/extensions/script/tests/PythonManifestTests.cpp
+++ b/extensions/script/tests/PythonManifestTests.cpp
@@ -46,7 +46,7 @@ TEST_CASE("Python processor's description is part of the 
manifest") {
   TestControllerWithFlow controller(empty_flow, false /* DEFER FLOW SETUP */);
 
   auto python_dir = 
std::filesystem::path(controller.configuration_->getHome()) / "minifi-python";
-  utils::file::create_dir(python_dir.string());
+  utils::file::create_dir(python_dir);
   std::ofstream{python_dir / "MyPyProc.py"} <<
     "def describe(proc):\n"
     "  proc.setDescription('An amazing processor')\n";
diff --git a/extensions/standard-processors/processors/GetFile.cpp 
b/extensions/standard-processors/processors/GetFile.cpp
index b3d0558fc..58f126eb0 100644
--- a/extensions/standard-processors/processors/GetFile.cpp
+++ b/extensions/standard-processors/processors/GetFile.cpp
@@ -17,15 +17,8 @@
  */
 #include "GetFile.h"
 
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include <cstring>
-#include <vector>
 #include <queue>
-#include <map>
 #include <memory>
-#include <regex>
 #include <string>
 
 #include "utils/StringUtils.h"
@@ -126,13 +119,14 @@ void GetFile::onSchedule(core::ProcessContext *context, 
core::ProcessSessionFact
     request_.fileFilter = value;
   }
 
-  if (!context->getProperty(Directory.getName(), value)) {
+  if (auto directory_str = context->getProperty(Directory)) {
+    if (!utils::file::is_directory(*directory_str)) {
+      throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Input Directory \"" + value 
+ "\" is not a directory");
+    }
+    request_.inputDirectory = *directory_str;
+  } else {
     throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Input Directory property is 
missing");
   }
-  if (!utils::file::is_directory(value)) {
-    throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Input Directory \"" + value + 
"\" is not a directory");
-  }
-  request_.inputDirectory = value;
 }
 
 void GetFile::onTrigger(core::ProcessContext* /*context*/, 
core::ProcessSession* session) {
@@ -164,9 +158,11 @@ void GetFile::getSingleFile(core::ProcessSession& session, 
const std::filesystem
   logger_->log_info("GetFile process %s", file_path.string());
   auto flow_file = session.create();
   gsl_Expects(flow_file);
+
   flow_file->setAttribute(core::SpecialFlowAttribute::FILENAME, 
file_path.filename().string());
-  flow_file->setAttribute(core::SpecialFlowAttribute::PATH, 
(file_path.parent_path() / "").string());
-  flow_file->addAttribute(core::SpecialFlowAttribute::ABSOLUTE_PATH, 
file_path.string());
+  flow_file->setAttribute(core::SpecialFlowAttribute::ABSOLUTE_PATH, 
std::filesystem::absolute(file_path.parent_path() / "").string());
+  auto relative_path = std::filesystem::relative(file_path.parent_path(), 
request_.inputDirectory);
+  flow_file->setAttribute(core::SpecialFlowAttribute::PATH, (relative_path / 
"").string());
 
   try {
     session.write(flow_file, utils::FileReaderCallback{file_path});
diff --git a/extensions/standard-processors/processors/GetFile.h 
b/extensions/standard-processors/processors/GetFile.h
index b320e07cd..1a287d38a 100644
--- a/extensions/standard-processors/processors/GetFile.h
+++ b/extensions/standard-processors/processors/GetFile.h
@@ -45,7 +45,7 @@ struct GetFileRequest {
   std::chrono::milliseconds pollInterval{0};
   uint64_t batchSize = 10;
   std::string fileFilter = ".*";
-  std::string inputDirectory;
+  std::filesystem::path inputDirectory;
 };
 
 class GetFileMetrics : public core::ProcessorMetrics {
diff --git a/extensions/standard-processors/processors/ListFile.cpp 
b/extensions/standard-processors/processors/ListFile.cpp
index f65595e1d..579728642 100644
--- a/extensions/standard-processors/processors/ListFile.cpp
+++ b/extensions/standard-processors/processors/ListFile.cpp
@@ -18,7 +18,6 @@
 
 #include <filesystem>
 
-#include "utils/FileReaderCallback.h"
 #include "utils/StringUtils.h"
 #include "core/PropertyBuilder.h"
 #include "core/Resource.h"
diff --git 
a/extensions/standard-processors/tests/unit/AttributesToJSONTests.cpp 
b/extensions/standard-processors/tests/unit/AttributesToJSONTests.cpp
index 11f82fd63..92550ef66 100644
--- a/extensions/standard-processors/tests/unit/AttributesToJSONTests.cpp
+++ b/extensions/standard-processors/tests/unit/AttributesToJSONTests.cpp
@@ -72,7 +72,7 @@ class AttributesToJSONTestFixture {
 
   void assertJSONAttributesFromFile(const std::unordered_map<std::string, 
std::optional<std::string>>& expected_attributes) {
     auto file_contents = getOutputFileContents();
-    REQUIRE(file_contents.size() == 1);
+    CHECK(file_contents.size() == 1);
     assertAttributes(expected_attributes, file_contents[0]);
   }
 
@@ -80,12 +80,12 @@ class AttributesToJSONTestFixture {
     rapidjson::Document root;
     rapidjson::ParseResult ok = root.Parse(output_json.c_str());
     REQUIRE(ok);
-    REQUIRE(root.MemberCount() == expected_attributes.size());
+    CHECK(root.MemberCount() == expected_attributes.size());
     for (const auto& [key, value] : expected_attributes) {
       if (value == std::nullopt) {
-        REQUIRE(root[key.c_str()].IsNull());
+        CHECK(root[key.c_str()].IsNull());
       } else {
-        REQUIRE(std::string(root[key.c_str()].GetString()) == value.value());
+        CHECK(std::string(root[key.c_str()].GetString()) == value.value());
       }
     }
   }
@@ -123,14 +123,14 @@ TEST_CASE_METHOD(AttributesToJSONTestFixture, "Move all 
attributes to a flowfile
   REQUIRE(file_contents[0] == TEST_FILE_CONTENT);
 
   const std::unordered_map<std::string, std::optional<std::string>> 
expected_attributes {
-    {"absolute.path", (dir_ / TEST_FILE_NAME).string()},
+    {"absolute.path", (dir_ / "").string()},
     {"empty_attribute", ""},
     {"filename", TEST_FILE_NAME},
     {"flow.id", "test"},
     {"my_attribute", "my_value"},
     {"my_attribute_1", "my_value_1"},
     {"other_attribute", "other_value"},
-    {"path", (dir_ / "").string()}
+    {"path", (std::filesystem::path(".") / "").string()}
   };
   assertJSONAttributesFromLog(expected_attributes);
 }
@@ -184,14 +184,14 @@ TEST_CASE_METHOD(AttributesToJSONTestFixture, "JSON 
attributes are written in fl
   test_controller_.runSession(plan_);
 
   const std::unordered_map<std::string, std::optional<std::string>> 
expected_attributes {
-    {"absolute.path", (dir_ / TEST_FILE_NAME).string()},
+    {"absolute.path", (dir_ / "").string()},
     {"empty_attribute", ""},
     {"filename", TEST_FILE_NAME},
     {"flow.id", "test"},
     {"my_attribute", "my_value"},
     {"my_attribute_1", "my_value_1"},
     {"other_attribute", "other_value"},
-    {"path", (dir_ / "").string()}
+    {"path", (std::filesystem::path(".") / "").string()}
   };
   assertJSONAttributesFromFile(expected_attributes);
 }
@@ -243,7 +243,7 @@ TEST_CASE_METHOD(AttributesToJSONTestFixture, "Attributes 
from attributes list a
     {"empty_attribute", ""},
     {"filename", TEST_FILE_NAME},
     {"my_attribute", "my_value"},
-    {"path", (dir_ / "").string()}
+    {"path", (std::filesystem::path(".") / "").string()}
   };
   assertJSONAttributesFromLog(expected_attributes);
 }
@@ -272,7 +272,7 @@ TEST_CASE_METHOD(AttributesToJSONTestFixture, "Core 
attributes are written if th
 
   const std::unordered_map<std::string, std::optional<std::string>> 
expected_attributes {
     {"filename", TEST_FILE_NAME},
-    {"path", (dir_ / "").string()},
+    {"path", (std::filesystem::path(".") / "").string()},
     {"my_attribute", "my_value"}
   };
   assertJSONAttributesFromLog(expected_attributes);
diff --git a/extensions/standard-processors/tests/unit/GetFileTests.cpp 
b/extensions/standard-processors/tests/unit/GetFileTests.cpp
index ec8979c1a..444953c85 100644
--- a/extensions/standard-processors/tests/unit/GetFileTests.cpp
+++ b/extensions/standard-processors/tests/unit/GetFileTests.cpp
@@ -16,13 +16,12 @@
  * limitations under the License.
  */
 #include <utility>
-#include <memory>
 #include <string>
-#include <fstream>
 #include <filesystem>
 #include <chrono>
 
 #include "TestBase.h"
+#include "SingleProcessorTestController.h"
 #include "Catch.h"
 #include "LogAttribute.h"
 #include "GetFile.h"
@@ -31,10 +30,6 @@
 #include "unit/ProvenanceTestHelper.h"
 #include "Utils.h"
 
-#ifdef WIN32
-#include <fileapi.h>
-#endif
-
 using namespace std::literals::chrono_literals;
 
 namespace {
@@ -76,12 +71,12 @@ GetFileTestController::GetFileTestController()
   auto log_attr = test_plan_->addProcessor("LogAttribute", "Log", 
core::Relationship("success", "description"), true);
   test_plan_->setProperty(log_attr, 
minifi::processors::LogAttribute::FlowFilesToLog.getName(), "0");
 
-  utils::putFileToDir(temp_dir_.string(), input_file_name_, "The quick brown 
fox jumps over the lazy dog\n");
-  utils::putFileToDir(temp_dir_.string(), large_input_file_name_, "The quick 
brown fox jumps over the lazy dog who is 2 legit to quit\n");
-  utils::putFileToDir(temp_dir_.string(), hidden_input_file_name_, "But noone 
has ever seen it\n");
+  utils::putFileToDir(temp_dir_, input_file_name_, "The quick brown fox jumps 
over the lazy dog\n");
+  utils::putFileToDir(temp_dir_, large_input_file_name_, "The quick brown fox 
jumps over the lazy dog who is 2 legit to quit\n");
+  utils::putFileToDir(temp_dir_, hidden_input_file_name_, "But noone has ever 
seen it\n");
 
 #ifdef WIN32
-  const auto hide_file_err = 
minifi::test::utils::hide_file(getFullPath(hidden_input_file_name_).c_str());
+  const auto hide_file_err = 
minifi::test::utils::hide_file(getFullPath(hidden_input_file_name_));
   REQUIRE(!hide_file_err);
 #endif
 }
@@ -269,3 +264,32 @@ TEST_CASE("Test if GetFile honors PollInterval property 
when triggered multiple
 
   REQUIRE(std::chrono::steady_clock::now() - start_time >= 100ms);
 }
+
+TEST_CASE("GetFile sets attributes correctly") {
+  using minifi::processors::GetFile;
+
+  const auto get_file = std::make_shared<GetFile>("GetFile");
+  LogTestController::getInstance().setTrace<GetFile>();
+  minifi::test::SingleProcessorTestController test_controller(get_file);
+  std::filesystem::path dir = test_controller.createTempDirectory();
+  get_file->setProperty(GetFile::Directory, dir.string());
+  SECTION("File in subdirectory of input directory") {
+    std::filesystem::create_directories(dir / "a" / "b");
+    utils::putFileToDir(dir / "a" / "b", "alpha.txt", "The quick brown fox 
jumps over the lazy dog\n");
+    auto result = test_controller.trigger();
+    REQUIRE((result.contains(GetFile::Success) && 
result.at(GetFile::Success).size() == 1));
+    auto flow_file = result.at(GetFile::Success)[0];
+    CHECK(flow_file->getAttribute(minifi::core::SpecialFlowAttribute::PATH) == 
(std::filesystem::path("a") / "b" / "").string());
+    
CHECK(flow_file->getAttribute(minifi::core::SpecialFlowAttribute::ABSOLUTE_PATH)
 == (dir / "a" / "b" / "").string());
+    
CHECK(flow_file->getAttribute(minifi::core::SpecialFlowAttribute::FILENAME) == 
"alpha.txt");
+  }
+  SECTION("File directly in input directory") {
+    utils::putFileToDir(dir, "beta.txt", "The quick brown fox jumps over the 
lazy dog\n");
+    auto result = test_controller.trigger();
+    REQUIRE((result.contains(GetFile::Success) && 
result.at(GetFile::Success).size() == 1));
+    auto flow_file = result.at(GetFile::Success)[0];
+    CHECK(flow_file->getAttribute(minifi::core::SpecialFlowAttribute::PATH) == 
(std::filesystem::path(".") / "").string());
+    
CHECK(flow_file->getAttribute(minifi::core::SpecialFlowAttribute::ABSOLUTE_PATH)
 == (dir / "").string());
+    
CHECK(flow_file->getAttribute(minifi::core::SpecialFlowAttribute::FILENAME) == 
"beta.txt");
+  }
+}
diff --git a/extensions/standard-processors/tests/unit/ListFileTests.cpp 
b/extensions/standard-processors/tests/unit/ListFileTests.cpp
index 7e52ccf14..46ce99b47 100644
--- a/extensions/standard-processors/tests/unit/ListFileTests.cpp
+++ b/extensions/standard-processors/tests/unit/ListFileTests.cpp
@@ -19,6 +19,7 @@
 #include <string>
 
 #include "TestBase.h"
+#include "SingleProcessorTestController.h"
 #include "Catch.h"
 #include "core/Property.h"
 #include "core/Processor.h"
@@ -217,4 +218,33 @@ TEST_CASE_METHOD(ListFileTestFixture, "Test listing hidden 
files", "[testListFil
   REQUIRE(verifyLogLinePresenceInPollTime(3s, "key:filename 
value:.hidden_file.txt"));
 }
 
+TEST_CASE("ListFile sets attributes correctly") {
+  using minifi::processors::ListFile;
+
+  const auto list_file = std::make_shared<ListFile>("GetFile");
+  LogTestController::getInstance().setTrace<ListFile>();
+  minifi::test::SingleProcessorTestController test_controller(list_file);
+  std::filesystem::path dir = test_controller.createTempDirectory();
+  list_file->setProperty(ListFile::InputDirectory, dir.string());
+  SECTION("File in subdirectory of input directory") {
+    std::filesystem::create_directories(dir / "a" / "b");
+    utils::putFileToDir(dir / "a" / "b", "alpha.txt", "The quick brown fox 
jumps over the lazy dog\n");
+    auto result = test_controller.trigger();
+    REQUIRE((result.contains(ListFile::Success) && 
result.at(ListFile::Success).size() == 1));
+    auto flow_file = result.at(ListFile::Success)[0];
+    CHECK(flow_file->getAttribute(minifi::core::SpecialFlowAttribute::PATH) == 
(std::filesystem::path("a") / "b" / "").string());
+    
CHECK(flow_file->getAttribute(minifi::core::SpecialFlowAttribute::ABSOLUTE_PATH)
 == (dir / "a" / "b" / "").string());
+    
CHECK(flow_file->getAttribute(minifi::core::SpecialFlowAttribute::FILENAME) == 
"alpha.txt");
+  }
+  SECTION("File directly in input directory") {
+    utils::putFileToDir(dir, "beta.txt", "The quick brown fox jumps over the 
lazy dog\n");
+    auto result = test_controller.trigger();
+    REQUIRE((result.contains(ListFile::Success) && 
result.at(ListFile::Success).size() == 1));
+    auto flow_file = result.at(ListFile::Success)[0];
+    CHECK(flow_file->getAttribute(minifi::core::SpecialFlowAttribute::PATH) == 
(std::filesystem::path(".") / "").string());
+    
CHECK(flow_file->getAttribute(minifi::core::SpecialFlowAttribute::ABSOLUTE_PATH)
 == (dir / "").string());
+    
CHECK(flow_file->getAttribute(minifi::core::SpecialFlowAttribute::FILENAME) == 
"beta.txt");
+  }
+}
+
 }  // namespace
diff --git a/extensions/standard-processors/tests/unit/ProcessorTests.cpp 
b/extensions/standard-processors/tests/unit/ProcessorTests.cpp
index d8d427316..b7afc647c 100644
--- a/extensions/standard-processors/tests/unit/ProcessorTests.cpp
+++ b/extensions/standard-processors/tests/unit/ProcessorTests.cpp
@@ -318,9 +318,9 @@ TEST_CASE("LogAttributeTest", "[getfileCreate3]") {
   records = plan->getProvenanceRecords();
   record = plan->getCurrentFlowFile();
 
-  REQUIRE(true == LogTestController::getInstance().contains("key:absolute.path 
value:" + path.string()));
-  REQUIRE(true == LogTestController::getInstance().contains("Size:8 
Offset:0"));
-  REQUIRE(true == LogTestController::getInstance().contains("key:path value:" 
+ dir.string()));
+  CHECK(true == LogTestController::getInstance().contains("key:absolute.path 
value:" + (dir / "").string()));
+  CHECK(true == LogTestController::getInstance().contains("Size:8 Offset:0"));
+  CHECK(true == LogTestController::getInstance().contains("key:path value:" + 
(std::filesystem::path(".") / "").string()));
   LogTestController::getInstance().reset();
 }
 
@@ -392,9 +392,9 @@ void testMultiplesLogAttribute(int fileCount, int 
flowsToLog, std::string verify
   records = plan->getProvenanceRecords();
   record = plan->getCurrentFlowFile();
 
-  REQUIRE(true == LogTestController::getInstance().contains("Size:8 
Offset:0"));
-  REQUIRE(true == LogTestController::getInstance().contains("key:path value:" 
+ dir.string()));
-  REQUIRE(true == LogTestController::getInstance().contains("Logged " + 
verifyStringFlowsLogged + " flow files"));
+  CHECK(true == LogTestController::getInstance().contains("Size:8 Offset:0"));
+  CHECK(true == LogTestController::getInstance().contains("key:path value:" + 
(std::filesystem::path(".") / "").string()));
+  CHECK(true == LogTestController::getInstance().contains("Logged " + 
verifyStringFlowsLogged + " flow files"));
   LogTestController::getInstance().reset();
 }
 
diff --git a/extensions/standard-processors/tests/unit/PutFileTests.cpp 
b/extensions/standard-processors/tests/unit/PutFileTests.cpp
index 91bc4dcb7..00f7fafbd 100644
--- a/extensions/standard-processors/tests/unit/PutFileTests.cpp
+++ b/extensions/standard-processors/tests/unit/PutFileTests.cpp
@@ -20,8 +20,6 @@
 #include <utility>
 #include <memory>
 #include <string>
-#include <vector>
-#include <set>
 #include <fstream>
 
 #include "utils/file/FileUtils.h"
@@ -35,8 +33,6 @@
 #include "core/Core.h"
 #include "core/FlowFile.h"
 #include "core/Processor.h"
-#include "core/ProcessContext.h"
-#include "core/ProcessSession.h"
 #include "core/ProcessorNode.h"
 #include "core/reporting/SiteToSiteProvenanceReportingTask.h"
 #include "Exception.h"
@@ -87,15 +83,13 @@ TEST_CASE("PutFileTest", "[getfileputpfile]") {
 
   testController.runSession(plan, false);
 
-  records = plan->getProvenanceRecords();
-  record = plan->getCurrentFlowFile();
   testController.runSession(plan, false);
 
   std::filesystem::remove(path);
 
-  REQUIRE(true == LogTestController::getInstance().contains("key:absolute.path 
value:" + path.string()));
+  REQUIRE(true == LogTestController::getInstance().contains("key:absolute.path 
value:" + (dir / "").string()));
   REQUIRE(true == LogTestController::getInstance().contains("Size:8 
Offset:0"));
-  REQUIRE(true == LogTestController::getInstance().contains("key:path value:" 
+ dir.string()));
+  REQUIRE(true == LogTestController::getInstance().contains("key:path value:" 
+ (std::filesystem::path(".") / "").string()));
   // verify that the fle was moved
   REQUIRE(false == std::ifstream(path).good());
   auto moved_path = putfiledir / "tstFile.ext";
@@ -155,15 +149,13 @@ TEST_CASE("PutFileTestFileExists", "[getfileputpfile]") {
 
   testController.runSession(plan, false);
 
-  records = plan->getProvenanceRecords();
-  record = plan->getCurrentFlowFile();
   testController.runSession(plan, false);
 
   std::filesystem::remove(path);
 
-  REQUIRE(true == LogTestController::getInstance().contains("key:absolute.path 
value:" + path.string()));
+  REQUIRE(true == LogTestController::getInstance().contains("key:absolute.path 
value:" + (dir / "").string()));
   REQUIRE(true == LogTestController::getInstance().contains("Size:8 
Offset:0"));
-  REQUIRE(true == LogTestController::getInstance().contains("key:path value:" 
+ dir.string()));
+  REQUIRE(true == LogTestController::getInstance().contains("key:path value:" 
+ (std::filesystem::path(".") / "").string()));
   // verify that the fle was moved
   REQUIRE(false == std::ifstream(path).good());
   REQUIRE(true == std::ifstream(moved_path).good());
@@ -219,15 +211,13 @@ TEST_CASE("PutFileTestFileExistsIgnore", 
"[getfileputpfile]") {
 
   testController.runSession(plan, false);
 
-  records = plan->getProvenanceRecords();
-  record = plan->getCurrentFlowFile();
   testController.runSession(plan, false);
 
   std::filesystem::remove(path);
 
-  REQUIRE(true == LogTestController::getInstance().contains("key:absolute.path 
value:" + path.string()));
+  REQUIRE(true == LogTestController::getInstance().contains("key:absolute.path 
value:" + (dir / "").string() ));
   REQUIRE(true == LogTestController::getInstance().contains("Size:8 
Offset:0"));
-  REQUIRE(true == LogTestController::getInstance().contains("key:path value:" 
+ dir.string()));
+  REQUIRE(true == LogTestController::getInstance().contains("key:path value:" 
+ (std::filesystem::path(".") / "").string()));
   // verify that the fle was moved
   REQUIRE(false == std::ifstream(path).good());
   REQUIRE(true == std::ifstream(moved_path).good());
@@ -283,15 +273,13 @@ TEST_CASE("PutFileTestFileExistsReplace", 
"[getfileputpfile]") {
 
   testController.runSession(plan, false);
 
-  records = plan->getProvenanceRecords();
-  record = plan->getCurrentFlowFile();
   testController.runSession(plan, false);
 
   std::filesystem::remove(path);
 
-  REQUIRE(true == LogTestController::getInstance().contains("key:absolute.path 
value:" + path.string()));
+  REQUIRE(true == LogTestController::getInstance().contains("key:absolute.path 
value:" + (dir / "").string()));
   REQUIRE(true == LogTestController::getInstance().contains("Size:8 
Offset:0"));
-  REQUIRE(true == LogTestController::getInstance().contains("key:path value:" 
+ dir.string()));
+  REQUIRE(true == LogTestController::getInstance().contains("key:path value:" 
+ (std::filesystem::path(".") / "").string()));
   // verify that the fle was moved
   REQUIRE(false == std::ifstream(path).good());
   REQUIRE(true == std::ifstream(moved_path).good());
@@ -349,9 +337,9 @@ TEST_CASE("PutFileMaxFileCountTest", 
"[getfileputpfilemaxcount]") {
   testController.runSession(plan);
 
 
-  CHECK(LogTestController::getInstance().contains("key:absolute.path value:" + 
(dir / "tstFile0.ext").string()));
-  CHECK(LogTestController::getInstance().contains("Size:8 Offset:0"));
-  CHECK(LogTestController::getInstance().contains("key:path value:" + 
dir.string()));
+  REQUIRE(LogTestController::getInstance().contains("key:absolute.path value:" 
+ (dir / "").string()));
+  REQUIRE(LogTestController::getInstance().contains("Size:8 Offset:0"));
+  REQUIRE(LogTestController::getInstance().contains("key:path value:" + 
(std::filesystem::path(".") / "").string()));
 
   // Only 1 of the 2 files should make it to the target dir
   // Non-deterministic, so let's just count them
diff --git a/extensions/standard-processors/tests/unit/TailFileTests.cpp 
b/extensions/standard-processors/tests/unit/TailFileTests.cpp
index 53c1d10ac..fd82b81c9 100644
--- a/extensions/standard-processors/tests/unit/TailFileTests.cpp
+++ b/extensions/standard-processors/tests/unit/TailFileTests.cpp
@@ -61,7 +61,7 @@ static const std::string ADDITIONALY_CREATED_FILE_CONTENT = 
"additional file dat
 namespace {
 std::filesystem::path createTempFile(const std::filesystem::path& directory, 
const std::filesystem::path& file_name, const std::string& contents,
     std::ios_base::openmode open_mode = std::ios::out | std::ios::binary) {
-  if (!utils::file::exists(directory.string())) {
+  if (!utils::file::exists(directory)) {
     std::filesystem::create_directories(directory);
   }
   std::string full_file_name = (directory / file_name).string();
diff --git a/libminifi/src/c2/C2Agent.cpp b/libminifi/src/c2/C2Agent.cpp
index 7fe53898a..fa1716894 100644
--- a/libminifi/src/c2/C2Agent.cpp
+++ b/libminifi/src/c2/C2Agent.cpp
@@ -1004,7 +1004,7 @@ void C2Agent::handleAssetUpdate(const C2ContentResponse& 
resp) {
 
   auto raw_data = std::move(file_response).moveRawData();
   // ensure directory exists for file
-  if (utils::file::create_dir(file_path.parent_path().string()) != 0) {
+  if (utils::file::create_dir(file_path.parent_path()) != 0) {
     send_error("Failed to create directory '" + 
file_path.parent_path().string() + "'");
     return;
   }
diff --git a/libminifi/test/unit/FilePatternTests.cpp 
b/libminifi/test/unit/FilePatternTests.cpp
index f00f6ab2d..42bc905ad 100644
--- a/libminifi/test/unit/FilePatternTests.cpp
+++ b/libminifi/test/unit/FilePatternTests.cpp
@@ -153,9 +153,9 @@ TEST_CASE("Matching directory with exclusion") {
   //   |        |- file5.txt
   //   |- two
   //       |- file6.txt
-  minifi::utils::file::create_dir((root / "one" / "apple").string(), true);
-  minifi::utils::file::create_dir((root / "one" / "banana").string(), true);
-  minifi::utils::file::create_dir((root / "two").string(), true);
+  minifi::utils::file::create_dir(root / "one" / "apple", true);
+  minifi::utils::file::create_dir(root / "one" / "banana", true);
+  minifi::utils::file::create_dir(root / "two", true);
 
   auto file1 = root / "file1.txt";
   auto file2 = root / "one" / "file2.txt";
@@ -261,8 +261,8 @@ TEST_CASE("Check only relevant subdir contents") {
   //   |
   //   |- two
   //       |- file3.txt
-  minifi::utils::file::create_dir((root / "one").string(), true);
-  minifi::utils::file::create_dir((root / "two").string(), true);
+  minifi::utils::file::create_dir(root / "one", true);
+  minifi::utils::file::create_dir(root / "two", true);
 
   auto file1 = root / "file1.txt";
   auto file2 = root / "one" / "file2.txt";
diff --git a/libminifi/test/unit/FileUtilsTests.cpp 
b/libminifi/test/unit/FileUtilsTests.cpp
index e71734650..fc87866b7 100644
--- a/libminifi/test/unit/FileUtilsTests.cpp
+++ b/libminifi/test/unit/FileUtilsTests.cpp
@@ -471,9 +471,9 @@ TEST_CASE("FileUtils::get_relative_path", 
"[TestGetRelativePath]") {
   TestController test_controller;
   const auto base_path = test_controller.createTempDirectory();
   auto path = std::filesystem::path{"/random/non-existent/dir"};
-  REQUIRE(FileUtils::get_relative_path(path.string(), base_path) == 
std::nullopt);
+  REQUIRE(FileUtils::get_relative_path(path, base_path) == std::nullopt);
   path = std::filesystem::path{base_path} / "subdir" / "file.log";
-  REQUIRE(*FileUtils::get_relative_path(path.string(), base_path) == 
std::filesystem::path("subdir") / "file.log");
-  REQUIRE(*FileUtils::get_relative_path(path.string(), base_path / "") == 
std::filesystem::path("subdir") / "file.log");
+  REQUIRE(*FileUtils::get_relative_path(path, base_path) == 
std::filesystem::path("subdir") / "file.log");
+  REQUIRE(*FileUtils::get_relative_path(path, base_path / "") == 
std::filesystem::path("subdir") / "file.log");
   REQUIRE(*FileUtils::get_relative_path(base_path, base_path) == ".");
 }

Reply via email to