From c01239c5e01e7df995893c3132147ef2a4c8ceb9 Mon Sep 17 00:00:00 2001 From: silverweed Date: Thu, 12 Dec 2024 14:16:22 +0100 Subject: [PATCH] [ntuple] change filesystem::path to std::string for fOutputPath --- tree/ntupleutil/v7/inc/ROOT/RNTupleExporter.hxx | 5 +++-- tree/ntupleutil/v7/src/RNTupleExporter.cxx | 2 +- tree/ntupleutil/v7/test/CMakeLists.txt | 4 ++++ tree/ntupleutil/v7/test/ntuple_exporter.cxx | 9 +++++---- tree/ntupleutil/v7/test/ntupleutil_test.hxx | 3 +-- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tree/ntupleutil/v7/inc/ROOT/RNTupleExporter.hxx b/tree/ntupleutil/v7/inc/ROOT/RNTupleExporter.hxx index a3ba684fa0ddc..c219b9bd2c15d 100644 --- a/tree/ntupleutil/v7/inc/ROOT/RNTupleExporter.hxx +++ b/tree/ntupleutil/v7/inc/ROOT/RNTupleExporter.hxx @@ -16,7 +16,8 @@ #ifndef ROOT7_RNTupleExporter #define ROOT7_RNTupleExporter -#include +#include +#include #include namespace ROOT::Experimental::Internal { @@ -35,7 +36,7 @@ public: kDefaults = kShowProgressBar }; - std::filesystem::path fOutputPath; + std::string fOutputPath; std::uint64_t fFlags; RPagesOptions() : fOutputPath("."), fFlags(kDefaults) {} diff --git a/tree/ntupleutil/v7/src/RNTupleExporter.cxx b/tree/ntupleutil/v7/src/RNTupleExporter.cxx index e3d6b53226093..adba049318520 100644 --- a/tree/ntupleutil/v7/src/RNTupleExporter.cxx +++ b/tree/ntupleutil/v7/src/RNTupleExporter.cxx @@ -134,7 +134,7 @@ RNTupleExporter::RPagesResult RNTupleExporter::ExportPages(RPageSource &source, const bool incChecksum = (options.fFlags & RPagesOptions::kIncludeChecksums) != 0 && pageInfo.fHasChecksum; const std::size_t maybeChecksumSize = incChecksum * 8; const std::uint64_t pageBufSize = pageInfo.fLocator.fBytesOnStorage + maybeChecksumSize; - std::ostringstream ss{options.fOutputPath.string(), std::ios_base::ate}; + std::ostringstream ss{options.fOutputPath, std::ios_base::ate}; ss << "/cluster_" << clusterDesc.GetId() << "_" << colInfo.fQualifiedName << "_page_" << pageIdx << "_elems_" << pageInfo.fNElements << "_comp_" << colRange.fCompressionSettings << ".page"; const auto outFileName = ss.str(); diff --git a/tree/ntupleutil/v7/test/CMakeLists.txt b/tree/ntupleutil/v7/test/CMakeLists.txt index a2308a0a958c0..9dfe739fbd9ac 100644 --- a/tree/ntupleutil/v7/test/CMakeLists.txt +++ b/tree/ntupleutil/v7/test/CMakeLists.txt @@ -22,3 +22,7 @@ endif() ROOT_ADD_GTEST(ntuple_importer ntuple_importer.cxx LIBRARIES ROOTNTupleUtil CustomStructUtil) ROOT_ADD_GTEST(ntuple_exporter ntuple_exporter.cxx LIBRARIES ROOTNTupleUtil) ROOT_ADD_GTEST(ntuple_inspector ntuple_inspector.cxx LIBRARIES ROOTNTupleUtil) + +if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) + target_link_libraries(ntuple_exporter stdc++fs) +endif() diff --git a/tree/ntupleutil/v7/test/ntuple_exporter.cxx b/tree/ntupleutil/v7/test/ntuple_exporter.cxx index 056f6a704a2b5..15b56ebff50cc 100644 --- a/tree/ntupleutil/v7/test/ntuple_exporter.cxx +++ b/tree/ntupleutil/v7/test/ntuple_exporter.cxx @@ -3,6 +3,7 @@ #include #include "ntupleutil_test.hxx" +#include using namespace ROOT::Experimental; @@ -268,7 +269,7 @@ TEST(RNTupleExporter, ExportToFilesCustomPath) } // create tmp directory - static const std::filesystem::path kDirName = "rntuple_exporter_custom_path"; + static const std::string kDirName = "rntuple_exporter_custom_path"; bool ok = std::filesystem::create_directory(kDirName); if (!ok) { FAIL() << "failed to create directory " << kDirName; @@ -286,9 +287,9 @@ TEST(RNTupleExporter, ExportToFilesCustomPath) EXPECT_EQ(res.fExportedFileNames.size(), 3); - FileRaii pageVecIdx(kDirName / "cluster_0_vec-0_page_0_elems_100_comp_505.page"); - FileRaii pageVec(kDirName / "cluster_0_vec._0-0_page_0_elems_2000_comp_505.page"); - FileRaii pageFlt(kDirName / "cluster_0_flt-0_page_0_elems_100_comp_505.page"); + FileRaii pageVecIdx(kDirName + "/cluster_0_vec-0_page_0_elems_100_comp_505.page"); + FileRaii pageVec(kDirName + "/cluster_0_vec._0-0_page_0_elems_2000_comp_505.page"); + FileRaii pageFlt(kDirName + "/cluster_0_flt-0_page_0_elems_100_comp_505.page"); EXPECT_TRUE(std::find(res.fExportedFileNames.begin(), res.fExportedFileNames.end(), pageFlt.GetPath()) != res.fExportedFileNames.end()); diff --git a/tree/ntupleutil/v7/test/ntupleutil_test.hxx b/tree/ntupleutil/v7/test/ntupleutil_test.hxx index 669691d528549..287acea7de756 100644 --- a/tree/ntupleutil/v7/test/ntupleutil_test.hxx +++ b/tree/ntupleutil/v7/test/ntupleutil_test.hxx @@ -9,7 +9,6 @@ #include #include #include -#include /** * An RAII wrapper around an open temporary file on disk. It cleans up the @@ -27,7 +26,7 @@ public: ~FileRaii() { if (!fPreserveFile) - std::filesystem::remove(fPath.c_str()); + std::remove(fPath.c_str()); } std::string GetPath() const { return fPath; }