Skip to content

Commit ca87ea0

Browse files
shahor02davidrohr
authored andcommitted
boost::filesystem -> std::filesystem
1 parent 63fe33e commit ca87ea0

18 files changed

Lines changed: 43 additions & 54 deletions

File tree

CCDB/src/CcdbApi.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include <TClass.h>
3232
#include <CCDB/CCDBTimeStampUtils.h>
3333
#include <algorithm>
34-
#include <boost/filesystem.hpp>
34+
#include <filesystem>
3535
#include <boost/algorithm/string.hpp>
3636
#include <iostream>
3737
#include <mutex>
@@ -334,8 +334,8 @@ void CcdbApi::retrieveBlob(std::string const& path, std::string const& targetdir
334334
// we setup the target path for this blob
335335
std::string fulltargetdir = targetdir + '/' + path;
336336

337-
if (!boost::filesystem::exists(fulltargetdir)) {
338-
if (!boost::filesystem::create_directories(fulltargetdir)) {
337+
if (!std::filesystem::exists(fulltargetdir)) {
338+
if (!std::filesystem::create_directories(fulltargetdir)) {
339339
std::cerr << "Could not create target directory " << fulltargetdir << "\n";
340340
}
341341
}
@@ -456,7 +456,7 @@ void* CcdbApi::extractFromTFile(TFile& file, TClass const* cl)
456456

457457
void* CcdbApi::extractFromLocalFile(std::string const& filename, std::type_info const& tinfo) const
458458
{
459-
if (!boost::filesystem::exists(filename)) {
459+
if (!std::filesystem::exists(filename)) {
460460
LOG(INFO) << "Local snapshot " << filename << " not found \n";
461461
return nullptr;
462462
}

CCDB/test/testCcdbApi.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "CommonUtils/RootChain.h" // just as test object
2323
#include "CCDB/CCDBTimeStampUtils.h"
2424
#include <boost/test/unit_test.hpp>
25-
#include <boost/filesystem.hpp>
25+
#include <filesystem>
2626
#include <cassert>
2727
#include <iostream>
2828
#include <cstdio>
@@ -179,8 +179,8 @@ BOOST_AUTO_TEST_CASE(store_retrieve_TMemFile_templated_test, *utf::precondition(
179179
// test the snapshot mechanism
180180
// ---------------------------
181181
// a) create a local snapshot of the Test folder
182-
auto ph = boost::filesystem::unique_path();
183-
boost::filesystem::create_directories(ph);
182+
auto ph = std::filesystem::temp_directory_path();
183+
std::filesystem::create_directories(ph);
184184
f.api.snapshot(basePath, ph.string(), o2::ccdb::getCurrentTimestamp());
185185
std::cout << "Creating snapshot at " << ph.string() << "\n";
186186

@@ -199,8 +199,8 @@ BOOST_AUTO_TEST_CASE(store_retrieve_TMemFile_templated_test, *utf::precondition(
199199
}
200200

201201
// d) cleanup local snapshot
202-
if (boost::filesystem::exists(ph)) {
203-
boost::filesystem::remove_all(ph);
202+
if (std::filesystem::exists(ph)) {
203+
std::filesystem::remove_all(ph);
204204
}
205205
}
206206

Common/SimConfig/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ o2_add_library(SimConfig
1515
src/DigiParams.cxx src/G4Params.cxx
1616
PUBLIC_LINK_LIBRARIES O2::CommonUtils
1717
O2::DetectorsCommonDataFormats
18-
FairRoot::Base Boost::program_options
19-
Boost::filesystem)
18+
FairRoot::Base Boost::program_options)
19+
2020

2121
o2_target_root_dictionary(SimConfig
2222
HEADERS include/SimConfig/SimConfig.h

Common/Utils/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ o2_add_library(CommonUtils
1515
src/StringUtils.cxx
1616
src/ConfigurableParamHelper.cxx src/ConfigurableParam.cxx src/RootSerializableKeyValueStore.cxx
1717
src/KeyValParam.cxx
18-
PUBLIC_LINK_LIBRARIES ROOT::Hist ROOT::Tree Boost::iostreams Boost::filesystem O2::CommonDataFormat O2::Headers
18+
PUBLIC_LINK_LIBRARIES ROOT::Hist ROOT::Tree Boost::iostreams O2::CommonDataFormat O2::Headers
1919
FairLogger::FairLogger)
2020

2121
o2_target_root_dictionary(CommonUtils

Common/Utils/src/ConfigurableParam.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "CommonUtils/StringUtils.h"
1515
#include "CommonUtils/KeyValParam.h"
1616
#include <boost/algorithm/string/predicate.hpp>
17-
#include <boost/filesystem.hpp>
1817
#include <boost/property_tree/ptree.hpp>
1918
#include <boost/property_tree/ini_parser.hpp>
2019
#include <boost/property_tree/json_parser.hpp>
@@ -36,6 +35,7 @@
3635
#include "TFile.h"
3736
#include "TEnum.h"
3837
#include "TEnumConstant.h"
38+
#include <filesystem>
3939

4040
namespace o2
4141
{
@@ -189,7 +189,7 @@ void ConfigurableParam::writeINI(std::string const& filename, std::string const&
189189
boost::property_tree::ptree ConfigurableParam::readConfigFile(std::string const& filepath)
190190
{
191191
auto inpfilename = o2::utils::Str::concat_string(sInputDir, filepath);
192-
if (!boost::filesystem::exists(inpfilename)) {
192+
if (!std::filesystem::exists(inpfilename)) {
193193
LOG(FATAL) << inpfilename << " : config file does not exist!";
194194
}
195195

Common/Utils/src/StringUtils.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ std::string Str::getRandomString(int lenght)
4646

4747
bool Str::pathExists(const std::string_view p)
4848
{
49-
return boost::filesystem::exists(std::string{p});
49+
return std::filesystem::exists(std::string{p});
5050
}
5151

5252
bool Str::pathIsDirectory(const std::string_view p)
5353
{
54-
return boost::filesystem::is_directory(std::string{p});
54+
return std::filesystem::is_directory(std::string{p});
5555
}
5656

5757
std::string Str::getFullPath(const std::string_view p)
5858
{
59-
return boost::filesystem::canonical(std::string{p}).generic_string();
59+
return std::filesystem::canonical(std::string{p}).string();
6060
}
6161

6262
std::string Str::rectifyDirectory(const std::string_view p)

Common/Utils/test/testCompStream.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define BOOST_TEST_MAIN
2020
#define BOOST_TEST_DYN_LINK
2121
#include <boost/test/unit_test.hpp>
22-
#include <boost/filesystem.hpp>
22+
#include <filesystem>
2323
#include <iostream>
2424
#include <iomanip>
2525
#include <sstream>
@@ -28,7 +28,7 @@ BOOST_AUTO_TEST_CASE(test_compstream_filesink)
2828
{
2929
const int range = 100;
3030
std::stringstream filename;
31-
filename << boost::filesystem::temp_directory_path().string() << "/" << boost::filesystem::unique_path().string()
31+
filename << std::filesystem::temp_directory_path().string() << "/" << std::filesystem::temp_directory_path().string()
3232
<< "_testCompStream.gz";
3333
{
3434
o2::io::ocomp_stream stream(filename.str().c_str(), o2::io::CompressionMethod::Gzip);
@@ -58,7 +58,7 @@ BOOST_AUTO_TEST_CASE(test_compstream_filesink)
5858
BOOST_CHECK(expected == range);
5959
}
6060

61-
boost::filesystem::remove(filename.str());
61+
std::filesystem::remove(filename.str());
6262
}
6363

6464
BOOST_AUTO_TEST_CASE(test_compstream_methods)

Common/Utils/test/testMemFileHelper.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#define BOOST_TEST_MAIN
1717
#define BOOST_TEST_DYN_LINK
1818
#include <boost/test/unit_test.hpp>
19-
#include <boost/filesystem.hpp>
19+
#include <filesystem>
2020
#include <cstdio>
2121
#include <vector>
2222
#include <TFile.h>

Detectors/TPC/simulation/src/GEMAmplification.cxx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "TPCBase/CDBInterface.h"
2020
#include <fstream>
2121
#include "FairLogger.h"
22+
#include <filesystem>
2223

2324
using namespace o2::tpc;
2425
using namespace o2::math_utils;
@@ -37,15 +38,9 @@ GEMAmplification::GEMAmplification()
3738
const float kappa = 1 / (sigmaOverMu * sigmaOverMu);
3839
boost::format polya("1/(TMath::Gamma(%1%)*%2%) * TMath::Power(x/%3%, %4%) * TMath::Exp(-x/%5%)");
3940

40-
// to be replaced by std::filesystem::exists once we have C++17
41-
auto fileexists = [](const char* fileName) -> bool {
42-
std::ifstream infile(fileName);
43-
return infile.good();
44-
};
45-
4641
const char* polyaFileName = "tpc_polya.root";
4742
TFile* outfile;
48-
auto cacheexists = fileexists(polyaFileName);
43+
auto cacheexists = std::filesystem::exists(polyaFileName);
4944
if (cacheexists) {
5045
LOG(INFO) << "TPC: GEM setup from existing cache";
5146
outfile = TFile::Open(polyaFileName);

Framework/Core/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88
# granted to it by virtue of its status as an Intergovernmental Organization or
99
# submit itself to any jurisdiction.
1010

11-
# Given GCC 7.3 does not provide std::filesystem we use Boost instead
12-
# Drop this once we move to GCC 8.2+
13-
# if (NOT __APPLE__)
14-
set(BOOST_FILESYSTEM Boost::filesystem)
15-
# endif()
16-
1711
o2_add_library(Framework
1812
SOURCES src/AODReaderHelpers.cxx
1913
src/ArrowSupport.cxx

0 commit comments

Comments
 (0)