From 1af13acb55d21a6f2d421114a653b682ff0943d2 Mon Sep 17 00:00:00 2001 From: Achim Gsell <achim.gsell@psi.ch> Date: Fri, 3 May 2024 20:59:57 +0200 Subject: [PATCH] boost::filesystem replaced with std::filesystem --- optimizer/Simulation/GenerateOpalSimulation.h | 2 +- src/Algorithms/OrbitThreader.cpp | 2 +- src/Algorithms/ParallelCyclotronTracker.cpp | 2 +- src/Amr/AmrYtWriter.cpp | 4 +-- src/BasicActions/DumpEMFields.cpp | 2 +- src/BasicActions/DumpFields.cpp | 2 +- src/Classic/AbsBeamline/Cyclotron.cpp | 2 +- src/Classic/AbsBeamline/ElementBase.cpp | 6 ++-- src/Classic/AbsBeamline/Monitor.cpp | 2 +- src/Classic/AbsBeamline/RFCavity.cpp | 2 +- src/Classic/AbsBeamline/Vacuum.cpp | 2 +- src/Classic/Fields/Fieldmap.cpp | 4 +-- src/Classic/Structure/LossDataSink.cpp | 2 +- src/Classic/Utilities/MSLang/Mask.cpp | 2 +- src/Classic/Utilities/Util.cpp | 2 +- src/Distribution/ClosedOrbitFinder.h | 2 +- src/Distribution/Distribution.cpp | 2 +- src/Distribution/LaserProfile.cpp | 2 +- src/Distribution/SigmaGenerator.cpp | 4 +-- src/Elements/OpalBeamline.cpp | 2 +- src/Main.cpp | 6 ++-- src/Optimize/OpalSimulation.cpp | 36 +++++++++---------- src/Optimize/OptimizeCmd.cpp | 4 +-- src/Sample/SampleCmd.cpp | 2 +- src/Sample/Sampler.cpp | 4 +-- src/Solvers/AMR_MG/AmrMultiGrid.cpp | 2 +- src/Structure/BoundaryGeometry.cpp | 11 +++--- src/Structure/FieldWriter.hpp | 4 +-- src/Structure/H5PartWrapper.cpp | 4 +-- src/Structure/MemoryProfiler.cpp | 2 +- src/Structure/SDDSWriter.cpp | 2 +- src/Structure/SDDSWriter.h | 2 +- .../BasicActions/DumpEMFieldsTest.cpp | 6 ++-- .../opal_src/BasicActions/DumpFieldsTest.cpp | 4 +-- 34 files changed, 68 insertions(+), 71 deletions(-) diff --git a/optimizer/Simulation/GenerateOpalSimulation.h b/optimizer/Simulation/GenerateOpalSimulation.h index d8460fe36..632fb6953 100644 --- a/optimizer/Simulation/GenerateOpalSimulation.h +++ b/optimizer/Simulation/GenerateOpalSimulation.h @@ -144,7 +144,7 @@ private: */ void fillDictionary() { - namespace fs = boost::filesystem; + namespace fs = std::filesystem; fs::path pwd = fs::current_path(); if (!fs::exists(varDictionary_) || fs::is_empty(varDictionary_)) diff --git a/src/Algorithms/OrbitThreader.cpp b/src/Algorithms/OrbitThreader.cpp index 9c06403e3..43c868955 100644 --- a/src/Algorithms/OrbitThreader.cpp +++ b/src/Algorithms/OrbitThreader.cpp @@ -73,7 +73,7 @@ OrbitThreader::OrbitThreader(const PartData &ref, opal->getInputBasename() + "_DesignPath.dat" }); if (opal->getOpenMode() == OpalData::OpenMode::WRITE || - !boost::filesystem::exists(fileName)) { + !std::filesystem::exists(fileName)) { logger_m.open(fileName); logger_m << "#" << std::setw(17) << "1 - s" diff --git a/src/Algorithms/ParallelCyclotronTracker.cpp b/src/Algorithms/ParallelCyclotronTracker.cpp index 015d6e4ce..b1d7825d1 100644 --- a/src/Algorithms/ParallelCyclotronTracker.cpp +++ b/src/Algorithms/ParallelCyclotronTracker.cpp @@ -1053,7 +1053,7 @@ void ParallelCyclotronTracker::visitVacuum(const Vacuum& vac) { *gmsg << "* Residual gas = " << gas << endl; double pressure = elptr->getPressure(); - if ( boost::filesystem::exists(elptr->getPressureMapFN()) ) { + if ( std::filesystem::exists(elptr->getPressureMapFN()) ) { std::string pmfn = elptr->getPressureMapFN(); *gmsg << "* Pressure field map file = '" << pmfn << "'" << endl; *gmsg << "* Default pressure = " << pressure << " [mbar]" << endl; diff --git a/src/Amr/AmrYtWriter.cpp b/src/Amr/AmrYtWriter.cpp index 0a5bed7de..27fe5655f 100644 --- a/src/Amr/AmrYtWriter.cpp +++ b/src/Amr/AmrYtWriter.cpp @@ -67,11 +67,11 @@ AmrYtWriter::AmrYtWriter(int step, int bin) { realData_m[idx++] ="magnetic_field_y"; realData_m[idx++] ="magnetic_field_z"; - namespace fs = boost::filesystem; + namespace fs = std::filesystem; fs::path dir = OpalData::getInstance()->getInputBasename(); std::string dataDir = OpalData::getInstance()->getAuxiliaryOutputDirectory(); - boost::filesystem::path path = dir.parent_path() / dataDir / "amr" / "yt"; + std::filesystem::path path = dir.parent_path() / dataDir / "amr" / "yt"; dir_m = amrex::Concatenate((path / "plt").string(), step, 10); dir_m += "-"; dir_m = amrex::Concatenate(dir_m, bin, 3); diff --git a/src/BasicActions/DumpEMFields.cpp b/src/BasicActions/DumpEMFields.cpp index b114c1f47..4f0c02882 100644 --- a/src/BasicActions/DumpEMFields.cpp +++ b/src/BasicActions/DumpEMFields.cpp @@ -292,7 +292,7 @@ void DumpEMFields::writeFieldThis(Component* field) { *gmsg << *this << endl; std::string fname; - if (boost::filesystem::path(filename_m).is_absolute() == true) { + if (std::filesystem::path(filename_m).is_absolute() == true) { fname = filename_m; } else { fname = Util::combineFilePath({ diff --git a/src/BasicActions/DumpFields.cpp b/src/BasicActions/DumpFields.cpp index 3103a69c5..6547544aa 100644 --- a/src/BasicActions/DumpFields.cpp +++ b/src/BasicActions/DumpFields.cpp @@ -146,7 +146,7 @@ void DumpFields::writeFieldThis(Component* field) { *gmsg << *this << endl; std::string fname; - if (boost::filesystem::path(filename_m).is_absolute() == true) { + if (std::filesystem::path(filename_m).is_absolute() == true) { fname = filename_m; } else { fname = Util::combineFilePath({ diff --git a/src/Classic/AbsBeamline/Cyclotron.cpp b/src/Classic/AbsBeamline/Cyclotron.cpp index 01207240f..c70a821cc 100644 --- a/src/Classic/AbsBeamline/Cyclotron.cpp +++ b/src/Classic/AbsBeamline/Cyclotron.cpp @@ -186,7 +186,7 @@ std::string Cyclotron::getFieldMapFN() const { throw GeneralClassicException( "Cyclotron::getFieldMapFN", "The attribute FMAPFN isn't set for the CYCLOTRON element"); - } else if (boost::filesystem::exists(fmapfn_m)) { + } else if (std::filesystem::exists(fmapfn_m)) { return fmapfn_m; } else { throw GeneralClassicException("Cyclotron::getFieldMapFN", diff --git a/src/Classic/AbsBeamline/ElementBase.cpp b/src/Classic/AbsBeamline/ElementBase.cpp index 869d23628..daeb17157 100644 --- a/src/Classic/AbsBeamline/ElementBase.cpp +++ b/src/Classic/AbsBeamline/ElementBase.cpp @@ -66,9 +66,7 @@ #include "Solvers/ParticleMatterInteractionHandler.h" #include "Solvers/WakeFunction.h" #include "Structure/BoundaryGeometry.h" - -#include <boost/filesystem.hpp> - +#include <filesystem> const std::map<ElementType, std::string> ElementBase::elementTypeToString_s = { {ElementType::ANY, "Any"}, @@ -180,7 +178,7 @@ std::string ElementBase::getOutputFN() const { if (outputfn_m.empty()) { return getName(); } else { - boost::filesystem::path filePath(outputfn_m); + std::filesystem::path filePath(outputfn_m); return filePath.replace_extension().native(); } } diff --git a/src/Classic/AbsBeamline/Monitor.cpp b/src/Classic/AbsBeamline/Monitor.cpp index 37ec547ee..0cccf0e84 100644 --- a/src/Classic/AbsBeamline/Monitor.cpp +++ b/src/Classic/AbsBeamline/Monitor.cpp @@ -164,7 +164,7 @@ void Monitor::initialise(PartBunchBase<double, 3> *bunch, double &startField, do if (OpalData::getInstance()->getOpenMode() == OpalData::OpenMode::WRITE || currentPosition < startField) { - namespace fs = boost::filesystem; + namespace fs = std::filesystem; fs::path lossFileName = fs::path(filename_m + ".h5"); if (fs::exists(lossFileName)) { diff --git a/src/Classic/AbsBeamline/RFCavity.cpp b/src/Classic/AbsBeamline/RFCavity.cpp index e1a15560d..60e76d924 100644 --- a/src/Classic/AbsBeamline/RFCavity.cpp +++ b/src/Classic/AbsBeamline/RFCavity.cpp @@ -347,7 +347,7 @@ std::string RFCavity::getFieldMapFN() const { throw GeneralClassicException("RFCavity::getFieldMapFN", "The attribute \"FMAPFN\" isn't set " "for the \"RFCAVITY\" element!"); - } else if (boost::filesystem::exists(filename_m)) { + } else if (std::filesystem::exists(filename_m)) { return filename_m; } else { throw GeneralClassicException("RFCavity::getFieldMapFN", diff --git a/src/Classic/AbsBeamline/Vacuum.cpp b/src/Classic/AbsBeamline/Vacuum.cpp index ea902932b..e8abe0e89 100644 --- a/src/Classic/AbsBeamline/Vacuum.cpp +++ b/src/Classic/AbsBeamline/Vacuum.cpp @@ -249,7 +249,7 @@ void Vacuum::initialise(PartBunchBase<double, 3>* bunch) { updateParticleAttributes(); - if (boost::filesystem::exists(pmapfn_m)) { + if (std::filesystem::exists(pmapfn_m)) { getPressureFromFile(); // calculate the radii of initial grid. initR(PP_m.rmin_m, PP_m.delr_m, PField_m.nrad_m); diff --git a/src/Classic/Fields/Fieldmap.cpp b/src/Classic/Fields/Fieldmap.cpp index 552d9e4f9..5bcb8416c 100644 --- a/src/Classic/Fields/Fieldmap.cpp +++ b/src/Classic/Fields/Fieldmap.cpp @@ -41,7 +41,7 @@ #include <fstream> #include <ios> -namespace fs = boost::filesystem; +namespace fs = std::filesystem; #define REGISTER_PARSE_TYPE(X) template <> struct _Fieldmap::TypeParseTraits<X> \ { static const char* name; } ; const char* _Fieldmap::TypeParseTraits<X>::name = #X @@ -744,7 +744,7 @@ void _Fieldmap::write3DField(unsigned int nx, if (Ippl::myNode() != 0 || (ef.size() != numpoints && bf.size() != numpoints)) return; - boost::filesystem::path p(Filename_m); + std::filesystem::path p(Filename_m); std::string fname = Util::combineFilePath({ OpalData::getInstance()->getAuxiliaryOutputDirectory(), p.stem().string() + ".vtk" diff --git a/src/Classic/Structure/LossDataSink.cpp b/src/Classic/Structure/LossDataSink.cpp index 853fdc788..40061695a 100644 --- a/src/Classic/Structure/LossDataSink.cpp +++ b/src/Classic/Structure/LossDataSink.cpp @@ -332,7 +332,7 @@ void LossDataSink::save(unsigned int numSets, OpalData::OpenMode openMode) { openMode = OpalData::getInstance()->getOpenMode(); } - namespace fs = boost::filesystem; + namespace fs = std::filesystem; if (h5hut_mode_m) { fileName_m = outputName_m + std::string(".h5"); if (openMode == OpalData::OpenMode::WRITE || !fs::exists(fileName_m)) { diff --git a/src/Classic/Utilities/MSLang/Mask.cpp b/src/Classic/Utilities/MSLang/Mask.cpp index ec70fa947..262dd22f1 100644 --- a/src/Classic/Utilities/MSLang/Mask.cpp +++ b/src/Classic/Utilities/MSLang/Mask.cpp @@ -127,7 +127,7 @@ namespace mslang { filename = filename.substr(1, filename.length() - 2); } - if (!boost::filesystem::exists(filename)) { + if (!std::filesystem::exists(filename)) { ERRORMSG("file '" << filename << "' doesn't exists" << endl); return false; } diff --git a/src/Classic/Utilities/Util.cpp b/src/Classic/Utilities/Util.cpp index 72e73b14e..b13ef3c16 100644 --- a/src/Classic/Utilities/Util.cpp +++ b/src/Classic/Utilities/Util.cpp @@ -195,7 +195,7 @@ namespace Util { } std::string combineFilePath(std::initializer_list<std::string> ilist) { - boost::filesystem::path path; + std::filesystem::path path; for (auto entry : ilist) { path /= entry; } diff --git a/src/Distribution/ClosedOrbitFinder.h b/src/Distribution/ClosedOrbitFinder.h index 5f900a15d..4eec5971c 100644 --- a/src/Distribution/ClosedOrbitFinder.h +++ b/src/Distribution/ClosedOrbitFinder.h @@ -456,7 +456,7 @@ bool ClosedOrbitFinder<Value_type, Size_type, Stepper>::findOrbit(value_type acc E_fin = cycl_m->getFMHighE(); } - namespace fs = boost::filesystem; + namespace fs = std::filesystem; fs::path dir = OpalData::getInstance()->getInputBasename(); dir = dir.parent_path() / OpalData::getInstance()->getAuxiliaryOutputDirectory(); std::string tunefile = (dir / "tunes.dat").string(); diff --git a/src/Distribution/Distribution.cpp b/src/Distribution/Distribution.cpp index 93468bd9a..a2a91b71f 100644 --- a/src/Distribution/Distribution.cpp +++ b/src/Distribution/Distribution.cpp @@ -1036,7 +1036,7 @@ void Distribution::createDistributionFromFile(size_t /*numberOfParticles*/, doub // Data input file is only read by node 0. std::ifstream inputFile; std::string fileName = Attributes::getString(itsAttr[Attrib::Distribution::FNAME]); - if (!boost::filesystem::exists(fileName)) { + if (!std::filesystem::exists(fileName)) { throw OpalException( "Distribution::createDistributionFromFile", "Open file operation failed, please check if '" + fileName + "' really exists."); diff --git a/src/Distribution/LaserProfile.cpp b/src/Distribution/LaserProfile.cpp index ce1790772..4d11369d1 100644 --- a/src/Distribution/LaserProfile.cpp +++ b/src/Distribution/LaserProfile.cpp @@ -82,7 +82,7 @@ LaserProfile::~LaserProfile() { unsigned short * LaserProfile::readFile(const std::string &fileName, const std::string &imageName) { - namespace fs = boost::filesystem; + namespace fs = std::filesystem; if (!fs::exists(fileName)) { throw OpalException("LaserProfile::readFile", "given file '" + fileName + "' does not exist"); diff --git a/src/Distribution/SigmaGenerator.cpp b/src/Distribution/SigmaGenerator.cpp index a71a483f2..bd511e11c 100644 --- a/src/Distribution/SigmaGenerator.cpp +++ b/src/Distribution/SigmaGenerator.cpp @@ -209,8 +209,8 @@ bool SigmaGenerator::match(double accuracy, OpalData::getInstance()->getAuxiliaryOutputDirectory(), "maps" }); - if (!boost::filesystem::exists(fpath)) { - boost::filesystem::create_directory(fpath); + if (!std::filesystem::exists(fpath)) { + std::filesystem::create_directory(fpath); } std::pair<double,double> tunes = cof.getTunes(); diff --git a/src/Elements/OpalBeamline.cpp b/src/Elements/OpalBeamline.cpp index bac23d44b..e3e5422ef 100644 --- a/src/Elements/OpalBeamline.cpp +++ b/src/Elements/OpalBeamline.cpp @@ -365,7 +365,7 @@ void OpalBeamline::save3DLattice() { OpalData::getInstance()->getInputBasename() + "_ElementPositions.txt" }); if (OpalData::getInstance()->getOpenMode() == OpalData::OpenMode::APPEND && - boost::filesystem::exists(fileName)) { + std::filesystem::exists(fileName)) { pos.open(fileName, std::ios_base::app); } else { pos.open(fileName); diff --git a/src/Main.cpp b/src/Main.cpp index 70e89a22a..0ac4a5b5d 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -147,7 +147,7 @@ int main(int argc, char *argv[]) { int opalMain(int argc, char *argv[]) { - namespace fs = boost::filesystem; + namespace fs = std::filesystem; #ifdef ENABLE_AMR bool initAMR = checkInitAmrFlag(argc, argv); @@ -186,7 +186,7 @@ int opalMain(int argc, char *argv[]) { */ if(Ippl::myNode() == 0) { if (!fs::exists(opal->getAuxiliaryOutputDirectory())) { - boost::system::error_code error_code; + std::error_code error_code; if (!fs::create_directory(opal->getAuxiliaryOutputDirectory(), error_code)) { std::cerr << error_code.message() << std::endl; // use error code to prevent create_directory from throwing an exception @@ -207,7 +207,7 @@ int opalMain(int argc, char *argv[]) { FileStream::setEcho(Options::echo); char *startup = getenv("HOME"); - boost::filesystem::path p = strncat(startup, "/init.opal", 20); + std::filesystem::path p = strncat(startup, "/init.opal", 20); if (startup != nullptr && is_regular_file(p)) { FileStream::setEcho(false); diff --git a/src/Optimize/OpalSimulation.cpp b/src/Optimize/OpalSimulation.cpp index fd4c0f313..cb6120469 100644 --- a/src/Optimize/OpalSimulation.cpp +++ b/src/Optimize/OpalSimulation.cpp @@ -48,7 +48,7 @@ OpalSimulation::OpalSimulation(Expressions::Named_t objectives, , comm_(comm) , id_m(-1) { - namespace fs = boost::filesystem; + namespace fs = std::filesystem; simTmpDir_ = args->getArg<std::string>("simtmpdir"); if (simTmpDir_.empty()) { @@ -155,7 +155,7 @@ bool OpalSimulation::hasResultsAvailable() { void OpalSimulation::createSymlink_m(const std::string& path) { - namespace fs = boost::filesystem; + namespace fs = std::filesystem; for (auto &p: fs::directory_iterator(path)) { fs::path source = p.path(); @@ -178,7 +178,7 @@ void OpalSimulation::copyH5_m() { if (restartfile.empty()) return; - namespace fs = boost::filesystem; + namespace fs = std::filesystem; if ( !fs::exists(restartfile) ) { std::cerr << "H5 file '" + restartfile + "' doesn't exist." << "\n" << "in OpalSimulation::copyH5_m()" << std::endl; @@ -198,7 +198,7 @@ void OpalSimulation::copyH5_m() { void OpalSimulation::setupSimulation() { - namespace fs = boost::filesystem; + namespace fs = std::filesystem; CmdArguments_t args = getArgs(); std::string restartfile = args->getArg<std::string>("restartfile", "", false); @@ -241,7 +241,7 @@ void OpalSimulation::setupSimulation() { } void OpalSimulation::setupFSStructure() { - namespace fs = boost::filesystem; + namespace fs = std::filesystem; int rank = 0; MPI_Comm_rank(comm_, &rank); @@ -254,11 +254,11 @@ void OpalSimulation::setupFSStructure() { try { fs::create_directory(simulationDirName_); fs::permissions(simulationDirName_, - fs::owner_all | - fs::group_read | - fs::group_exe | - fs::others_read | - fs::others_exe); + fs::perms::owner_all | + fs::perms::group_read | + fs::perms::group_exec | + fs::perms::others_read | + fs::perms::others_exec); } catch (fs::filesystem_error &e) { std::cerr << e.what() << "\n" @@ -271,11 +271,11 @@ void OpalSimulation::setupFSStructure() { fs::create_directory(dataDir); fs::permissions(dataDir, - fs::owner_all | - fs::group_read | - fs::group_exe | - fs::others_read | - fs::others_exe); + fs::perms::owner_all | + fs::perms::group_read | + fs::perms::group_exec | + fs::perms::others_read | + fs::perms::others_exec); } catch (fs::filesystem_error &e) { std::cerr << e.what() << "\n" @@ -326,7 +326,7 @@ void OpalSimulation::restoreOut() { void OpalSimulation::run() { - namespace fs = boost::filesystem; + namespace fs = std::filesystem; // make sure input file is not already existing MPI_Barrier(comm_); @@ -623,7 +623,7 @@ void OpalSimulation::invalidBunch() { } void OpalSimulation::cleanUp() { - namespace fs = boost::filesystem; + namespace fs = std::filesystem; try { int my_rank = 0; MPI_Comm_rank(comm_, &my_rank); @@ -639,7 +639,7 @@ void OpalSimulation::cleanUp() { } void OpalSimulation::cleanUp(const std::vector<std::string>& keep) { - namespace fs = boost::filesystem; + namespace fs = std::filesystem; if ( keep.empty() ) { // if empty we keep all files diff --git a/src/Optimize/OptimizeCmd.cpp b/src/Optimize/OptimizeCmd.cpp index 7dc555dc1..f4cc616b0 100644 --- a/src/Optimize/OptimizeCmd.cpp +++ b/src/Optimize/OptimizeCmd.cpp @@ -57,8 +57,6 @@ #include "Expression/ProbeVariable.h" #include "Expression/SeptumExpr.h" -#include <boost/filesystem.hpp> - #include <map> #include <set> #include <string> @@ -196,7 +194,7 @@ OptimizeCmd *OptimizeCmd::clone(const std::string &name) { } void OptimizeCmd::execute() { - namespace fs = boost::filesystem; + namespace fs = std::filesystem; auto opal = OpalData::getInstance(); opal->setOptimizerFlag(); diff --git a/src/Sample/SampleCmd.cpp b/src/Sample/SampleCmd.cpp index b9dcbbc75..f7aaffb47 100644 --- a/src/Sample/SampleCmd.cpp +++ b/src/Sample/SampleCmd.cpp @@ -147,7 +147,7 @@ SampleCmd *SampleCmd::clone(const std::string &name) { void SampleCmd::execute() { - namespace fs = boost::filesystem; + namespace fs = std::filesystem; auto opal = OpalData::getInstance(); opal->setOptimizerFlag(); diff --git a/src/Sample/Sampler.cpp b/src/Sample/Sampler.cpp index ba55f778d..92fc1a8a3 100644 --- a/src/Sample/Sampler.cpp +++ b/src/Sample/Sampler.cpp @@ -76,8 +76,8 @@ Sampler::Sampler(const std::map<std::string, << "_samples_" << comms_.island_id << ".json"; jsonFname_m = filename.str(); - if ( !boost::filesystem::exists(resultDir) ) { - boost::filesystem::create_directory(resultDir); + if ( !std::filesystem::exists(resultDir) ) { + std::filesystem::create_directory(resultDir); } DVarContainer_t::iterator itr; diff --git a/src/Solvers/AMR_MG/AmrMultiGrid.cpp b/src/Solvers/AMR_MG/AmrMultiGrid.cpp index 23864e50e..96fdce063 100644 --- a/src/Solvers/AMR_MG/AmrMultiGrid.cpp +++ b/src/Solvers/AMR_MG/AmrMultiGrid.cpp @@ -100,7 +100,7 @@ AmrMultiGrid::AmrMultiGrid(AmrBoxLib* itsAmrObject_p, const BaseSolver solver = this->convertToEnumBaseSolver_m(bsolver); this->initBaseSolver_m(solver, rebalance, reuse); - if (boost::filesystem::exists(fname_m)) { + if (std::filesystem::exists(fname_m)) { flag_m = std::ios::app; INFOMSG("Appending solver information to existing file: " << fname_m << endl); } else { diff --git a/src/Structure/BoundaryGeometry.cpp b/src/Structure/BoundaryGeometry.cpp index a2480cb41..25783bea2 100644 --- a/src/Structure/BoundaryGeometry.cpp +++ b/src/Structure/BoundaryGeometry.cpp @@ -1623,13 +1623,14 @@ BoundaryGeometry::computeMeshVoxelization (void) { }); bool writeVTK = false; - if (!boost::filesystem::exists(vtkFileName)) { + if (!std::filesystem::exists(vtkFileName)) { writeVTK = true; } else { - std::time_t t_geom = boost::filesystem::last_write_time(h5FileName_m); - std::time_t t_vtk = boost::filesystem::last_write_time(vtkFileName); - if (std::difftime(t_geom,t_vtk) > 0) + auto t_geom = boost::filesystem::last_write_time(h5FileName_m); + auto t_vtk = boost::filesystem::last_write_time(vtkFileName); + if (std::difftime(t_geom, t_vtk) > 0) { writeVTK = true; + } } if (writeVTK) { @@ -2024,7 +2025,7 @@ Change orientation if diff is: *gmsg << level2 << "* Initializing Boundary Geometry..." << endl; IpplTimings::startTimer (Tinitialize_m); - if (!boost::filesystem::exists(h5FileName_m)) { + if (!std::filesystem::exists(h5FileName_m)) { throw OpalException("BoundaryGeometry::initialize", "Failed to open file '" + h5FileName_m + "', please check if it exists"); diff --git a/src/Structure/FieldWriter.hpp b/src/Structure/FieldWriter.hpp index f26f7338f..1e90d46eb 100644 --- a/src/Structure/FieldWriter.hpp +++ b/src/Structure/FieldWriter.hpp @@ -55,8 +55,8 @@ void FieldWriter::dumpField(FieldType& field, std::string name, * '******': step padded with zeros to 6 digits */ std::string dirname = OpalData::getInstance()->getAuxiliaryOutputDirectory(); - boost::filesystem::path file(dirname); - boost::format filename("%1%-%2%-%|3$06|.dat"); + std::filesystem::path file(dirname); + std::format filename("%1%-%2%-%|3$06|.dat"); std::string basename = OpalData::getInstance()->getInputBasename(); filename % basename % (name + std::string("_") + type) % step; file /= filename.str(); diff --git a/src/Structure/H5PartWrapper.cpp b/src/Structure/H5PartWrapper.cpp index 6a03872f1..2947bdf3e 100644 --- a/src/Structure/H5PartWrapper.cpp +++ b/src/Structure/H5PartWrapper.cpp @@ -128,7 +128,7 @@ void H5PartWrapper::storeCavityInformation() { void H5PartWrapper::copyFile(const std::string &sourceFile, int lastStep, h5_int32_t flags) { - namespace fs = boost::filesystem; + namespace fs = std::filesystem; if (!fs::exists(sourceFile)) { throw OpalException("H5PartWrapper::copyFile", "source file '" + sourceFile + "' does not exist"); @@ -252,7 +252,7 @@ void H5PartWrapper::copyFile(const std::string &sourceFile, int lastStep, h5_int } void H5PartWrapper::copyFileSystem(const std::string &sourceFile) { - // namespace fs = boost::filesystem; + // namespace fs = std::filesystem; if (sourceFile == fileName_m) return; diff --git a/src/Structure/MemoryProfiler.cpp b/src/Structure/MemoryProfiler.cpp index 53dbc1ef3..22d758d05 100644 --- a/src/Structure/MemoryProfiler.cpp +++ b/src/Structure/MemoryProfiler.cpp @@ -146,7 +146,7 @@ void MemoryProfiler::update() { static pid_t pid = getpid(); std::string fname = "/proc/" + std::to_string(pid) + "/status"; - if ( !boost::filesystem::exists(fname) ) { + if ( !std::filesystem::exists(fname) ) { throw OpalException("MemoryProfiler::update()", "File '" + fname + "' doesn't exist."); } diff --git a/src/Structure/SDDSWriter.cpp b/src/Structure/SDDSWriter.cpp index 73433b05a..911c8ee5f 100644 --- a/src/Structure/SDDSWriter.cpp +++ b/src/Structure/SDDSWriter.cpp @@ -34,7 +34,7 @@ SDDSWriter::SDDSWriter(const std::string& fname, bool restart) , mode_m(std::ios::out) , indent_m(" ") { - namespace fs = boost::filesystem; + namespace fs = std::filesystem; if (fs::exists(fname_m) && restart) { mode_m = std::ios::app; diff --git a/src/Structure/SDDSWriter.h b/src/Structure/SDDSWriter.h index 5858415d6..97e2739f9 100644 --- a/src/Structure/SDDSWriter.h +++ b/src/Structure/SDDSWriter.h @@ -153,7 +153,7 @@ private: inline bool SDDSWriter::exists() const { - return boost::filesystem::exists(fname_m); + return std::filesystem::exists(fname_m); } diff --git a/tests/opal_src/BasicActions/DumpEMFieldsTest.cpp b/tests/opal_src/BasicActions/DumpEMFieldsTest.cpp index e9922db0c..69d746488 100644 --- a/tests/opal_src/BasicActions/DumpEMFieldsTest.cpp +++ b/tests/opal_src/BasicActions/DumpEMFieldsTest.cpp @@ -145,7 +145,7 @@ void clear_files(std::set<std::string> const& files) { std::string auxDirectory = OpalData::getInstance()->getAuxiliaryOutputDirectory(); for (const std::string& fname : files) { - boost::filesystem::remove(Util::combineFilePath({auxDirectory, fname})); + std::filesystem::remove(Util::combineFilePath({auxDirectory, fname})); } } @@ -153,7 +153,7 @@ TEST(DumpEMFieldsTest, writeFieldsCartTest) { OpalTestUtilities::SilenceTest silencer; std::string auxDirectory = OpalData::getInstance()->getAuxiliaryOutputDirectory(); - boost::filesystem::create_directory(auxDirectory); + std::filesystem::create_directory(auxDirectory); std::string fname1 = "test5"; std::string fname2 = "test6"; @@ -226,7 +226,7 @@ TEST(DumpEMFieldsTest, writeFieldsCylTest) { OpalTestUtilities::SilenceTest silencer; std::string auxDirectory = OpalData::getInstance()->getAuxiliaryOutputDirectory(); - boost::filesystem::create_directory(auxDirectory); + std::filesystem::create_directory(auxDirectory); std::string fnameCyl = "testCyl"; diff --git a/tests/opal_src/BasicActions/DumpFieldsTest.cpp b/tests/opal_src/BasicActions/DumpFieldsTest.cpp index f3895dd48..f12b0a312 100644 --- a/tests/opal_src/BasicActions/DumpFieldsTest.cpp +++ b/tests/opal_src/BasicActions/DumpFieldsTest.cpp @@ -113,7 +113,7 @@ void clear_files(std::set<std::string> const& files) { std::string auxDirectory = OpalData::getInstance()->getAuxiliaryOutputDirectory(); for (const std::string& fname : files) { - boost::filesystem::remove(Util::combineFilePath({auxDirectory, fname})); + std::filesystem::remove(Util::combineFilePath({auxDirectory, fname})); } } @@ -122,7 +122,7 @@ TEST(DumpFieldsTest, writeFieldsTest) { std::string auxDirectory = OpalData::getInstance()->getAuxiliaryOutputDirectory(); - boost::filesystem::create_directory(auxDirectory); + std::filesystem::create_directory(auxDirectory); std::string fname1 = "test1"; std::string fname2 = "test2"; -- GitLab