diff --git a/optimizer/Simulation/GenerateOpalSimulation.h b/optimizer/Simulation/GenerateOpalSimulation.h index d8460fe3632b16153a0df31af143d19509419208..eb42749924d28d0737a2e55b8dfa5cbf8dad9f43 100644 --- a/optimizer/Simulation/GenerateOpalSimulation.h +++ b/optimizer/Simulation/GenerateOpalSimulation.h @@ -42,7 +42,6 @@ #include <vector> #include <boost/algorithm/string.hpp> -#include "boost/filesystem.hpp" #include "Util/OptPilotException.h" @@ -144,7 +143,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 9c06403e3718552b8f3aad2009ac2ba3fd768457..34108e3bf2be7274629c39402d5a6f4da8a866f6 100644 --- a/src/Algorithms/OrbitThreader.cpp +++ b/src/Algorithms/OrbitThreader.cpp @@ -34,8 +34,6 @@ #include "Utilities/Options.h" #include "Utilities/Util.h" -#include <boost/filesystem.hpp> - #include <cmath> #include <iostream> #include <limits> @@ -73,7 +71,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 015d6e4ce3134107ae0dc09eaf615e18bd6806ae..3d7b86f0a6ebe6e6263bbe55ba0395170b8a2d9e 100644 --- a/src/Algorithms/ParallelCyclotronTracker.cpp +++ b/src/Algorithms/ParallelCyclotronTracker.cpp @@ -84,8 +84,6 @@ #include "Utilities/OpalException.h" #include "Utilities/Options.h" -#include <boost/filesystem.hpp> - #include <cmath> #include <fstream> #include <iostream> @@ -1053,7 +1051,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 0a5bed7de31d85bfaca15d3aabf71e38b37764b4..27fe5655fd9e121e9c9e3f2d4b92f8cb663738a5 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/Amr/AmrYtWriter.h b/src/Amr/AmrYtWriter.h index 65cd04bd6c874674734518c45cbb1d900ea2f5d9..e9e250ecbcf1be8ace6181f41e5bc416f7a8b5d0 100644 --- a/src/Amr/AmrYtWriter.h +++ b/src/Amr/AmrYtWriter.h @@ -27,8 +27,6 @@ #include "Amr/AbstractAmrWriter.h" -#include <boost/filesystem.hpp> - #include <vector> class AmrYtWriter: public AbstractAmrWriter { diff --git a/src/BasicActions/DumpEMFields.cpp b/src/BasicActions/DumpEMFields.cpp index b114c1f476927a0bf1c32458570620327416eb5d..37c965278836d9e99408b24893d17f99120246d8 100644 --- a/src/BasicActions/DumpEMFields.cpp +++ b/src/BasicActions/DumpEMFields.cpp @@ -26,8 +26,6 @@ #include "Utilities/OpalException.h" #include "Utilities/Util.h" -#include <boost/filesystem.hpp> - #include <cmath> #include <fstream> #include <map> @@ -292,7 +290,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 3103a69c54a020d0e1a9996502e70dbae14fd3e2..066e8da2d2cbe14e2b152e2d79ce2bb355805070 100644 --- a/src/BasicActions/DumpFields.cpp +++ b/src/BasicActions/DumpFields.cpp @@ -24,8 +24,6 @@ #include "Utilities/OpalException.h" #include "Utilities/Util.h" -#include <boost/filesystem.hpp> - #include <fstream> extern Inform* gmsg; @@ -146,7 +144,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 01207240ff4928df54fddb6015f108fc8d683305..a2319032b0dde686474921acc9a9458030271aa4 100644 --- a/src/Classic/AbsBeamline/Cyclotron.cpp +++ b/src/Classic/AbsBeamline/Cyclotron.cpp @@ -37,8 +37,6 @@ #include "Utilities/GeneralClassicException.h" #include "Utilities/Util.h" -#include <boost/filesystem.hpp> - #include <cmath> #include <cstring> #include <cstdio> @@ -186,7 +184,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 869d23628c5e76d5f562b5e2836d64e0de75fa68..daeb171572dc1d1b2a9f0ad814b14c8311e75393 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 37ec547ee48219500076bfb09ad8bc8ce0d16af3..3fb3ce902c2fd498c8402b11f9b471caf329a6c1 100644 --- a/src/Classic/AbsBeamline/Monitor.cpp +++ b/src/Classic/AbsBeamline/Monitor.cpp @@ -27,8 +27,6 @@ #include "Utilities/Options.h" #include "Utilities/Util.h" -#include <boost/filesystem.hpp> - #include <fstream> #include <memory> @@ -164,7 +162,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 e1a15560d0caedcc2a64325fe0ef9020b36cb74b..78e74ad3bdd43149081841966d1e886479abbf8e 100644 --- a/src/Classic/AbsBeamline/RFCavity.cpp +++ b/src/Classic/AbsBeamline/RFCavity.cpp @@ -26,7 +26,6 @@ #include "Utilities/Util.h" #include <boost/assign.hpp> -#include <boost/filesystem.hpp> #include "gsl/gsl_interp.h" #include "gsl/gsl_spline.h" @@ -347,7 +346,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 ea902932bd027a6f559b35682b70e5f29fc9b55b..3edfb2e4ece0d99945deac0c016b4eaffbe503ca 100644 --- a/src/Classic/AbsBeamline/Vacuum.cpp +++ b/src/Classic/AbsBeamline/Vacuum.cpp @@ -32,7 +32,6 @@ #include "Utilities/LogicalError.h" #include <boost/assign.hpp> -#include <boost/filesystem.hpp> #include <cmath> #include <cstdio> @@ -249,7 +248,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 552d9e4f9d1799bfec23a4ac4261145b4aa0dbba..16660f26cf4b44a63079547a858705816b8524bf 100644 --- a/src/Classic/Fields/Fieldmap.cpp +++ b/src/Classic/Fields/Fieldmap.cpp @@ -34,14 +34,12 @@ #include "H5hut.h" -#include <boost/filesystem.hpp> - #include <cmath> #include <iostream> #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 +742,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 853fdc7888b647008e43f81b945829d97954aadf..b382ecae88147e53295280dc654560cd8054f7c4 100644 --- a/src/Classic/Structure/LossDataSink.cpp +++ b/src/Classic/Structure/LossDataSink.cpp @@ -27,8 +27,6 @@ #include "Utility/IpplInfo.h" -#include <boost/filesystem.hpp> - #include <cmath> extern Inform* gmsg; @@ -332,7 +330,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 ec70fa947a9a452daa04abd62acfe0ba8acb73b2..de79e6a10e0545fa7d7ef07faff42ca443ea2125 100644 --- a/src/Classic/Utilities/MSLang/Mask.cpp +++ b/src/Classic/Utilities/MSLang/Mask.cpp @@ -4,7 +4,6 @@ #include "Utilities/PortableBitmapReader.h" #include <boost/regex.hpp> -#include <boost/filesystem.hpp> namespace { void updateCache(const std::vector<bool> &pixels, std::vector<int> &cache, int x, int width) { @@ -127,7 +126,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 72e73b14eca7255054d64d4031c6f858739798b4..4a1ee771bb75d5c0f8d018c694060d3e70131a63 100644 --- a/src/Classic/Utilities/Util.cpp +++ b/src/Classic/Utilities/Util.cpp @@ -20,7 +20,6 @@ #include "OPALrevision.h" #include "Utilities/OpalException.h" -#include <boost/filesystem.hpp> #include <boost/regex.hpp> #include <cctype> @@ -195,7 +194,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 5f900a15d171f9efedc1e79e554c9d4b512c605e..48db4d201b10988fd08b9bda6e38bf754b1512c7 100644 --- a/src/Distribution/ClosedOrbitFinder.h +++ b/src/Distribution/ClosedOrbitFinder.h @@ -46,7 +46,6 @@ // include headers for integration #include <boost/numeric/odeint/integrate/integrate_n_steps.hpp> -#include <boost/filesystem.hpp> extern Inform *gmsg; @@ -456,7 +455,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 93468bd9af0daf6f712e9a90546fda1d5ed9e1bf..0a0283848248d336f32d4b89fdca8fe46570c1e0 100644 --- a/src/Distribution/Distribution.cpp +++ b/src/Distribution/Distribution.cpp @@ -44,7 +44,6 @@ #include <gsl/gsl_rng.h> #include <gsl/gsl_sf_erf.h> -#include <boost/filesystem.hpp> #include <boost/regex.hpp> #include <boost/numeric/odeint/stepper/runge_kutta4.hpp> @@ -1036,7 +1035,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 ce17907721b0d3d7d6791cb0e4a89ca8a5b083c3..ea3a01b552ad67d26b34aadbafafe298aa2da7ac 100644 --- a/src/Distribution/LaserProfile.cpp +++ b/src/Distribution/LaserProfile.cpp @@ -17,8 +17,6 @@ #include "Utilities/PortableGraymapReader.h" #include "Utilities/Util.h" -#include <boost/filesystem.hpp> - #include <fstream> #include <iostream> #include <cmath> @@ -82,7 +80,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 a71a483f2dc608b56afc53a3593b575290bd9f23..d2165156582c03f97dddacce26f6f67fc30b61cd 100644 --- a/src/Distribution/SigmaGenerator.cpp +++ b/src/Distribution/SigmaGenerator.cpp @@ -46,8 +46,6 @@ #include <sstream> #include <utility> -#include <boost/filesystem.hpp> - #include <boost/numeric/odeint/stepper/runge_kutta4.hpp> extern Inform *gmsg; @@ -209,8 +207,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 bac23d44b4aeada47439a07762f7a53d8c70fd69..1151cf77081bab8edc88a09649376b46562a8e41 100644 --- a/src/Elements/OpalBeamline.cpp +++ b/src/Elements/OpalBeamline.cpp @@ -24,7 +24,6 @@ #include "Utilities/Options.h" #include "Utilities/Util.h" -#include <boost/filesystem.hpp> #include <boost/regex.hpp> #include <fstream> @@ -365,7 +364,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 70e89a22a12d2972ebe28d885e0f19200bf854ff..d0bbcd7e5255ab674002a114f7f0eec6e954b29f 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -49,7 +49,6 @@ #include <gsl/gsl_errno.h> -#include <boost/filesystem.hpp> #include <boost/system/error_code.hpp> #include <cstring> @@ -147,7 +146,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 +185,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 +206,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 fd4c0f3139aa3a5423d0a3432ed0cf68b653bcda..6e387c4fa6e6625ee1d251c51bbdc1b503c0309e 100644 --- a/src/Optimize/OpalSimulation.cpp +++ b/src/Optimize/OpalSimulation.cpp @@ -28,9 +28,6 @@ #include "boost/smart_ptr.hpp" #include "boost/algorithm/string.hpp" -#include "boost/filesystem.hpp" -#include "boost/filesystem/operations.hpp" - // access to OPAL lib #include "opal.h" #include "Utilities/OpalException.h" @@ -48,7 +45,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 +152,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 +175,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 +195,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 +238,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 +251,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 +268,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 +323,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 +620,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 +636,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 7dc555dc1c01f36da82a7d365f481710676eb357..f4cc616b0ad93eb6452e727772854266e37a7583 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 b9dcbbc75567d46d3006493d8d9b7311ded84a90..332db33de446038da2a45e1aa22df4df7d66134b 100644 --- a/src/Sample/SampleCmd.cpp +++ b/src/Sample/SampleCmd.cpp @@ -56,8 +56,6 @@ #include "Expression/ProbeVariable.h" #include "Expression/SeptumExpr.h" -#include <boost/filesystem.hpp> - #include <map> #include <set> #include <string> @@ -147,7 +145,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 ba55f778dd8b74cca756b860f578eeeea48a2610..2f5c164f966c1ba8d819ba4cdb8adc1c5e94dc53 100644 --- a/src/Sample/Sampler.cpp +++ b/src/Sample/Sampler.cpp @@ -34,8 +34,6 @@ #include <boost/property_tree/json_parser.hpp> #include <boost/property_tree/ptree.hpp> -#include <boost/filesystem.hpp> - Sampler::Sampler(Expressions::Named_t /*objectives*/, Expressions::Named_t /*constraints*/, DVarContainer_t /*dvars*/, @@ -76,8 +74,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 23864e50e07740f0a1c5646b8f30aba14e9c4607..2593cd87fdc9505591cb66cb3e3f043f206c11c2 100644 --- a/src/Solvers/AMR_MG/AmrMultiGrid.cpp +++ b/src/Solvers/AMR_MG/AmrMultiGrid.cpp @@ -35,8 +35,6 @@ #include <AMReX_ParallelDescriptor.H> -#include <boost/filesystem.hpp> - #if AMR_MG_WRITE #include <iomanip> #endif @@ -100,7 +98,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 a2480cb41f7bbd80157b37d7c666dd0fe6e8d012..10343d65fe87ad312aa08cf8718af76d3001d3dd 100644 --- a/src/Structure/BoundaryGeometry.cpp +++ b/src/Structure/BoundaryGeometry.cpp @@ -37,10 +37,10 @@ #include "Utilities/OpalException.h" #include "Utilities/Options.h" -#include <boost/filesystem.hpp> - #include <gsl/gsl_sys.h> +#include <boost/filesystem.hpp> + extern Inform* gmsg; #define SQR(x) ((x)*(x)) @@ -1623,13 +1623,16 @@ 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) + // here we keep using boost::filesystem. See + // https://stackoverflow.com/questions/51273205/how-to-compare-time-t-and-stdfilesystemfile-time-type + 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 +2027,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 f26f7338f7c8ee75972357246de1312eebf460be..b360dff96553a37b07ff024cd43e0bf3bee1c32a 100644 --- a/src/Structure/FieldWriter.hpp +++ b/src/Structure/FieldWriter.hpp @@ -19,7 +19,6 @@ #include <iomanip> #include <fstream> -#include <boost/filesystem.hpp> #include <boost/format.hpp> #include "Utilities/Util.h" @@ -55,8 +54,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 6a03872f17921c28309920dac030b24f2ef6ad0b..ac84f85b9aaca8e44e3c8f9941a98fd2e2568863 100644 --- a/src/Structure/H5PartWrapper.cpp +++ b/src/Structure/H5PartWrapper.cpp @@ -15,8 +15,6 @@ #include "Message/Message.h" #include "Utility/PAssert.h" -#include <boost/filesystem.hpp> - #include <fstream> namespace { @@ -128,7 +126,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 +250,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 53dbc1ef3204b444c742ffdf30e7e1b3d43ffbc3..1e4683276291b7692b60d029d05ced25fb12230d 100644 --- a/src/Structure/MemoryProfiler.cpp +++ b/src/Structure/MemoryProfiler.cpp @@ -28,8 +28,6 @@ #include "Ippl.h" -#include <boost/filesystem.hpp> - #ifdef __linux__ #include <sys/types.h> #include <unistd.h> @@ -146,7 +144,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 73433b05a8ce83a5c4e50f181ba9c49a7c46701d..911c8ee5fc9463d7fe2c0ec7131988c1ddd6ab8e 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 5858415d66f91eeab7d27b8bb447d8941d5a667b..2ceadd0ea51e7bf7d0c6167e8e987ccc1d6dd54d 100644 --- a/src/Structure/SDDSWriter.h +++ b/src/Structure/SDDSWriter.h @@ -30,8 +30,6 @@ #include <utility> #include <vector> -#include <boost/filesystem.hpp> - #include "Structure/SDDSColumn.h" #include "Structure/SDDSColumnSet.h" @@ -153,7 +151,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 e9922db0c8b72c832c6e3e940dbdd17e6e4e9374..daca62a467fdc9f7ff2af6cc71f505ab968bda09 100644 --- a/tests/opal_src/BasicActions/DumpEMFieldsTest.cpp +++ b/tests/opal_src/BasicActions/DumpEMFieldsTest.cpp @@ -41,8 +41,6 @@ #include "opal_test_utilities/SilenceTest.h" -#include "boost/filesystem.hpp" - namespace DumpEMFieldsTest { void setOneAttribute(DumpEMFields* dump, std::string name, double value) { @@ -145,7 +143,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 +151,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 +224,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 f3895dd48a2d8f6eba758e5490ea683e9e067cd8..8401469782bc8cd0b16fc7aa84a6ec2e1e7bbc74 100644 --- a/tests/opal_src/BasicActions/DumpFieldsTest.cpp +++ b/tests/opal_src/BasicActions/DumpFieldsTest.cpp @@ -39,8 +39,6 @@ #include "opal_test_utilities/SilenceTest.h" -#include "boost/filesystem.hpp" - namespace test { void test() {} @@ -113,7 +111,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 +120,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";