mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-11-03 12:47:42 -06:00
Create ensureDirectoryExists() free function.
This commit is contained in:
1 parent
431abb0012
commit
d267c1a77d
3 files changed
+87
No files matched your search
@@ -63,6 +63,7 @@ list (APPEND MAIN_SOURCE_FILES
|
||||
opm/polymer/TransportSolverTwophasePolymer.cpp
|
||||
opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp
|
||||
opm/polymer/fullyimplicit/PolymerPropsAd.cpp
|
||||
opm/simulators/ensureDirectoryExists.cpp
|
||||
opm/simulators/SimulatorCompressibleTwophase.cpp
|
||||
opm/simulators/SimulatorIncompTwophase.cpp
|
||||
opm/simulators/WellSwitchingLogger.cpp
|
||||
@@ -258,6 +259,7 @@ list (APPEND PUBLIC_HEADER_FILES
|
||||
opm/polymer/fullyimplicit/SimulatorFullyImplicitBlackoilPolymer.hpp
|
||||
opm/polymer/fullyimplicit/SimulatorFullyImplicitBlackoilPolymer_impl.hpp
|
||||
opm/polymer/fullyimplicit/WellStateFullyImplicitBlackoilPolymer.hpp
|
||||
opm/simulators/ensureDirectoryExists.hpp
|
||||
opm/simulators/ParallelFileMerger.hpp
|
||||
opm/simulators/SimulatorCompressibleTwophase.hpp
|
||||
opm/simulators/SimulatorIncompTwophase.hpp
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
|
||||
Copyright 2017 Statoil ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <opm/simulators/ensureDirectoryExists.hpp>
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
/// The directory pointed to by 'dirpath' will be created if it
|
||||
/// does not already exist. Will throw an exception if this cannot
|
||||
/// be done.
|
||||
void ensureDirectoryExists(const boost::filesystem::path& dirpath)
|
||||
{
|
||||
if (dirpath != ".") { // Do not try to create the current directory.
|
||||
if (!is_directory(dirpath)) {
|
||||
try {
|
||||
create_directories(dirpath);
|
||||
}
|
||||
catch (...) {
|
||||
OPM_THROW(std::runtime_error, "Creating directories failed: " << dirpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace Opm
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
|
||||
Copyright 2017 Statoil ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef OPM_ENSUREDIRECTORYEXISTS_HEADER_INCLUDED
|
||||
#define OPM_ENSUREDIRECTORYEXISTS_HEADER_INCLUDED
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
/// The directory pointed to by 'dirpath' will be created if it
|
||||
/// does not already exist. Will throw an exception if this cannot
|
||||
/// be done.
|
||||
///
|
||||
/// Note that std::string can be passed to this functions, as they
|
||||
/// can be implicitly converted to boost::filesystem::path objects.
|
||||
void ensureDirectoryExists(const boost::filesystem::path& dirpath);
|
||||
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
#endif // OPM_ENSUREDIRECTORYEXISTS_HEADER_INCLUDED
|
||||
Reference in new issue
Block a user