changed: use std::filesystem instead of boost::filesystem

since we still support g++-7, where filesystem is marked experimental,
we introduce a wrapper header and expose the namespace to use
as Opm::filesystem.

for gcc we unconditionally link with libstdc++fs in the python bindings.
the setup.py stuff links as c code, not c++ code, so it is not
automatically added on any gcc version. this might prove unportable
later.
This commit is contained in:
Arne Morten Kvarving 2020-02-12 09:12:29 +01:00
parent 679c7a2a5c
commit fb75bcd4e2
38 changed files with 306 additions and 204 deletions

View File

@ -31,6 +31,7 @@ list (APPEND MAIN_SOURCE_FILES
src/opm/common/OpmLog/StreamLog.cpp
src/opm/common/OpmLog/TimerLog.cpp
src/opm/common/utility/ActiveGridCells.cpp
src/opm/common/utility/FileSystem.cpp
src/opm/common/utility/numeric/MonotCubicInterpolator.cpp
src/opm/common/utility/parameters/Parameter.cpp
src/opm/common/utility/parameters/ParameterGroup.cpp
@ -470,6 +471,7 @@ list( APPEND PUBLIC_HEADER_FILES
opm/common/OpmLog/StreamLog.hpp
opm/common/OpmLog/TimerLog.hpp
opm/common/utility/ActiveGridCells.hpp
opm/common/utility/FileSystem.hpp
opm/common/utility/numeric/cmp.hpp
opm/common/utility/platform_dependent/disable_warnings.h
opm/common/utility/platform_dependent/reenable_warnings.h

View File

@ -32,7 +32,7 @@ if(NOT cjson_FOUND)
endif()
add_executable(genkw ${genkw_SOURCES})
target_link_libraries(genkw Boost::filesystem Boost::system)
target_link_libraries(genkw ${opm-common_LIBRARIES})
# Generate keyword list
include(src/opm/parser/eclipse/share/keywords/keyword_list.cmake)

View File

@ -91,3 +91,9 @@ CHECK_CXX_SOURCE_COMPILES("
};
" HAS_ATTRIBUTE_DEPRECATED_MSG
)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSRSION VERSION_LESS 8.0)
list(APPEND ${project}_LIBRARIES stdc++fs)
endif()
endif()

View File

@ -19,8 +19,8 @@
#include <iostream>
#include <getopt.h>
#include <boost/filesystem.hpp>
#include <opm/common/utility/FileSystem.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
@ -95,10 +95,10 @@ int main(int argc, char** argv) {
pack_deck(argv[arg_offset], std::cout);
else {
std::ofstream os;
using path = boost::filesystem::path;
using path = Opm::filesystem::path;
path input_arg(argv[arg_offset]);
path output_arg(coutput_arg);
if (boost::filesystem::is_directory(output_arg)) {
if (Opm::filesystem::is_directory(output_arg)) {
path output_path = output_arg / input_arg.filename();
os.open(output_path.string());
} else

View File

@ -9,20 +9,11 @@ set (opm-common_CONFIG_VAR
set (opm-common_DEPS
# compile with C99 support if available
"C99"
)
)
list(APPEND opm-common_DEPS
# various runtime library enhancements
"Boost 1.44.0 COMPONENTS system unit_test_framework REQUIRED"
)
if(ENABLE_ECL_INPUT)
list(APPEND opm-common_DEPS
# various runtime library enhancements
"Boost 1.44.0
COMPONENTS system filesystem unit_test_framework REQUIRED")
else()
list(APPEND opm-common_DEPS
# various runtime library enhancements
"Boost 1.44.0
COMPONENTS system unit_test_framework REQUIRED")
endif()
# We need a defined target for libecl when linking.
# The definition of the target is done implicitly below when
# libecl is searched for.
find_package_deps(opm-common)

View File

@ -0,0 +1,46 @@
/*
Copyright 2019 Equinor 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_FILESYSTEM_HPP
#define OPM_FILESYSTEM_HPP
#if __cplusplus__ >= 201703L
#include <filesystem>
#else
#include <experimental/filesystem>
#endif
#include <string>
namespace Opm
{
#if __cplusplus__ >= 201703L
namespace filesystem = std::filesystem;
#else
namespace filesystem = std::experimental::filesystem;
#endif
// A poor man's filesystem::unique_path
std::string unique_path(const std::string& input);
} // end namespace Opm
#endif // OPM_FILESYSTEM_HPP

View File

@ -21,7 +21,7 @@
#include <string>
#include <vector>
#include <boost/filesystem.hpp>
#include <opm/common/utility/FileSystem.hpp>
namespace Opm { namespace EclIO {
@ -54,13 +54,13 @@ private:
std::vector<int> seqIndex;
std::vector<float> seqTime;
std::vector<std::string> checkForMultipleResultFiles(const boost::filesystem::path& rootN, bool formatted) const;
std::vector<std::string> checkForMultipleResultFiles(const Opm::filesystem::path& rootN, bool formatted) const;
void getRstString(const std::vector<std::string>& restartArray,
boost::filesystem::path& pathRst,
boost::filesystem::path& rootN) const;
Opm::filesystem::path& pathRst,
Opm::filesystem::path& rootN) const;
void updatePathAndRootName(boost::filesystem::path& dir, boost::filesystem::path& rootN) const;
void updatePathAndRootName(Opm::filesystem::path& dir, Opm::filesystem::path& rootN) const;
std::string makeKeyString(const std::string& keyword, const std::string& wgname, int num) const;
};

View File

@ -22,7 +22,7 @@
#include <string>
#include <boost/filesystem/path.hpp>
#include <opm/common/utility/FileSystem.hpp>
struct cJSON;
@ -30,7 +30,7 @@ namespace Json {
class JsonObject {
public:
explicit JsonObject(const boost::filesystem::path& jsonFile );
explicit JsonObject(const Opm::filesystem::path& jsonFile );
explicit JsonObject(const std::string& inline_json);
explicit JsonObject(const char * inline_json);
explicit JsonObject(cJSON * root);

View File

@ -26,8 +26,6 @@
#include <vector>
#include <string>
#include <boost/filesystem.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/Units/UnitSystem.hpp>

View File

@ -21,6 +21,7 @@
#ifndef OPM_TABLE_MANAGER_HPP
#define OPM_TABLE_MANAGER_HPP
#include <cassert>
#include <set>
#include <opm/common/OpmLog/OpmLog.hpp>

View File

@ -25,7 +25,6 @@
#include <string>
#include <vector>
#include <boost/filesystem/path.hpp>
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
namespace Opm {

View File

@ -26,7 +26,7 @@
#include <string>
#include <vector>
#include <list>
#include <boost/filesystem.hpp>
#include <opm/common/utility/FileSystem.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
@ -86,9 +86,9 @@ namespace Opm {
std::vector<std::string> getAllDeckNames () const;
void loadKeywords(const Json::JsonObject& jsonKeywords);
bool loadKeywordFromFile(const boost::filesystem::path& configFile);
bool loadKeywordFromFile(const Opm::filesystem::path& configFile);
void loadKeywordsFromDirectory(const boost::filesystem::path& directory , bool recursive = true);
void loadKeywordsFromDirectory(const Opm::filesystem::path& directory , bool recursive = true);
void applyUnitsToDeck(Deck& deck) const;
/*!

View File

@ -7,6 +7,7 @@ import setuptools
import glob
import os
import re
import subprocess
try:
from importlib.machinery import EXTENSION_SUFFIXES
@ -23,6 +24,14 @@ try:
cc = os.environ.get("CC", "c++")
os.environ['CC'] = 'ccache {}'.format(cc)
print("Using 'ccache {}' as compiler".format(cc))
# This is very hacky but so is the entire setup.py buildsystem.
output=subprocess.check_output([cc, "--version"])
libs=['opmcommon', 'boost_system']
output=str(output)
if output.find('Free Software Foundation'):
libs.append('stdc++fs')
except OSError as e:
print('\nNOTE: please install ccache for faster compilation of python bindings.\n')
@ -54,7 +63,7 @@ ext_modules = [
'cxx/well.cpp',
'cxx/export.cpp'
],
libraries=['opmcommon', 'boost_filesystem', 'boost_regex'],
libraries=libs,
language='c++',
undef_macros=["NDEBUG"],
include_dirs=["pybind11/include"],

View File

@ -0,0 +1,50 @@
/*
Copyright 2019 Equinor 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/common/utility/FileSystem.hpp>
#include <algorithm>
#include <random>
namespace Opm
{
std::string unique_path(const std::string& input)
{
std::random_device rd;
std::mt19937 gen(rd());
auto randchar = [&gen]()
{
const std::string set = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
std::uniform_int_distribution<> select(0, set.size()-1);
return set[select(gen)];
};
std::string ret;
ret.reserve(input.size());
std::transform(input.begin(), input.end(), std::back_inserter(ret),
[&randchar](const char c)
{
return (c == '%') ? randchar() : c;
});
return ret;
}
}

View File

@ -32,7 +32,7 @@
#include <stdexcept>
#include <iostream>
#include <boost/filesystem.hpp>
#include <opm/common/utility/FileSystem.hpp>
#include <opm/io/eclipse/EclFile.hpp>
/*
@ -60,8 +60,8 @@ namespace Opm { namespace EclIO {
ESmry::ESmry(const std::string &filename, bool loadBaseRunData)
{
boost::filesystem::path inputFileName(filename);
boost::filesystem::path rootName = inputFileName.parent_path() / inputFileName.stem();
Opm::filesystem::path inputFileName(filename);
Opm::filesystem::path rootName = inputFileName.parent_path() / inputFileName.stem();
// if root name (without any extension) given as first argument in constructor, binary will then be assumed
if (inputFileName.extension()==""){
@ -77,15 +77,15 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData)
bool formatted = inputFileName.extension()==".SMSPEC" ? false : true;
formattedVect.push_back(formatted);
boost::filesystem::path path = boost::filesystem::current_path();;
Opm::filesystem::path path = Opm::filesystem::current_path();;
updatePathAndRootName(path, rootName);
boost::filesystem::path smspec_file = path / rootName;
Opm::filesystem::path smspec_file = path / rootName;
smspec_file += inputFileName.extension();
boost::filesystem::path rstRootN;
boost::filesystem::path pathRstFile = path;
Opm::filesystem::path rstRootN;
Opm::filesystem::path pathRstFile = path;
std::set<std::string> keywList;
std::vector<std::pair<std::string,int>> smryArray;
@ -124,13 +124,13 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData)
while ((rstRootN.string() != "") && (loadBaseRunData)) {
boost::filesystem::path rstFile = pathRstFile / rstRootN;
Opm::filesystem::path rstFile = pathRstFile / rstRootN;
rstFile += ".SMSPEC";
bool baseRunFmt = false;
// if unformatted file not exists, check for formatted file
if (!boost::filesystem::exists(rstFile)){
if (!Opm::filesystem::exists(rstFile)){
rstFile = pathRstFile / rstRootN;
rstFile += ".FSMSPEC";
@ -230,7 +230,7 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData)
toReportStepNumber = std::numeric_limits<int>::max();
}
boost::filesystem::path smspecFile(std::get<0>(smryArray[n]));
Opm::filesystem::path smspecFile(std::get<0>(smryArray[n]));
rootName = smspecFile.parent_path() / smspecFile.stem();
@ -239,11 +239,11 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData)
// if both unified and non-unified files exists, will use most recent based on
// time stamp
boost::filesystem::path unsmryFile = rootName;
Opm::filesystem::path unsmryFile = rootName;
formattedVect[n] ? unsmryFile += ".FUNSMRY" : unsmryFile += ".UNSMRY";
bool use_unified = boost::filesystem::exists(unsmryFile.string());
bool use_unified = Opm::filesystem::exists(unsmryFile.string());
std::vector<std::string> multFileList = checkForMultipleResultFiles(rootName, formattedVect[n]);
@ -252,8 +252,8 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData)
if ((!use_unified) && (multFileList.size()==0)){
throw std::runtime_error("neigther unified or non-unified result files found");
} else if ((use_unified) && (multFileList.size()>0)){
auto time_multiple = boost::filesystem::last_write_time(multFileList.back());
auto time_unified = boost::filesystem::last_write_time(unsmryFile);
auto time_multiple = Opm::filesystem::last_write_time(multFileList.back());
auto time_unified = Opm::filesystem::last_write_time(unsmryFile);
if (time_multiple > time_unified){
resultsFileList=multFileList;
@ -374,14 +374,14 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData)
}
std::vector<std::string> ESmry::checkForMultipleResultFiles(const boost::filesystem::path& rootN, bool formatted) const {
std::vector<std::string> ESmry::checkForMultipleResultFiles(const Opm::filesystem::path& rootN, bool formatted) const {
std::vector<std::string> fileList;
std::string pathRootN = rootN.parent_path().string();
std::string fileFilter = formatted ? rootN.stem().string()+".A" : rootN.stem().string()+".S";
for (boost::filesystem::directory_iterator itr(pathRootN); itr!=boost::filesystem::directory_iterator(); ++itr)
for (Opm::filesystem::directory_iterator itr(pathRootN); itr != Opm::filesystem::directory_iterator(); ++itr)
{
std::string file = itr->path().filename().string();
@ -395,7 +395,7 @@ std::vector<std::string> ESmry::checkForMultipleResultFiles(const boost::filesys
return fileList;
}
void ESmry::getRstString(const std::vector<std::string>& restartArray, boost::filesystem::path& pathRst, boost::filesystem::path& rootN) const {
void ESmry::getRstString(const std::vector<std::string>& restartArray, Opm::filesystem::path& pathRst, Opm::filesystem::path& rootN) const {
std::string rootNameStr="";
@ -403,12 +403,12 @@ void ESmry::getRstString(const std::vector<std::string>& restartArray, boost::fi
rootNameStr = rootNameStr + str;
}
rootN = boost::filesystem::path(rootNameStr);
rootN = Opm::filesystem::path(rootNameStr);
updatePathAndRootName(pathRst, rootN);
}
void ESmry::updatePathAndRootName(boost::filesystem::path& dir, boost::filesystem::path& rootN) const {
void ESmry::updatePathAndRootName(Opm::filesystem::path& dir, Opm::filesystem::path& rootN) const {
if (rootN.parent_path().is_absolute()){
dir = rootN.parent_path();

View File

@ -38,7 +38,7 @@
#include <utility>
#include <vector>
#include <boost/filesystem.hpp>
#include <opm/common/utility/FileSystem.hpp>
namespace {
namespace FileExtension
@ -396,7 +396,7 @@ openUnified(const std::string& fname,
// to be an actual unified restart file.
throw std::invalid_argument {
"Purported existing unified restart file '"
+ boost::filesystem::path{fname}.filename().string()
+ Opm::filesystem::path{fname}.filename().string()
+ "' does not appear to be a unified restart file"
};
}
@ -444,7 +444,7 @@ openExisting(const std::string& fname,
// resize_file() followed by seekp() is the intended and expected
// order of operations.
boost::filesystem::resize_file(fname, writePos);
Opm::filesystem::resize_file(fname, writePos);
if (! this->stream_->ofileH.seekp(0, std::ios_base::end)) {
throw std::invalid_argument {
@ -800,7 +800,7 @@ std::string
Opm::EclIO::OutputStream::outputFileName(const ResultSet& rsetDescriptor,
const std::string& ext)
{
namespace fs = boost::filesystem;
namespace fs = Opm::filesystem;
// Allow baseName = "CASE", "CASE.", "CASE.N", or "CASE.N.".
auto fname = fs::path {

View File

@ -23,8 +23,7 @@
#include <fstream>
#include <stdexcept>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <opm/common/utility/FileSystem.hpp>
#include <opm/json/JsonObject.hpp>
#include <cJSON.h>
@ -49,7 +48,7 @@ namespace Json {
JsonObject::JsonObject(const boost::filesystem::path& jsonFile ) {
JsonObject::JsonObject(const Opm::filesystem::path& jsonFile ) {
std::ifstream stream(jsonFile.string().c_str());
if (stream) {
std::string content_from_file( (std::istreambuf_iterator<char>(stream)),

View File

@ -54,8 +54,7 @@
#include <unordered_map>
#include <utility> // move
#include <boost/filesystem.hpp>
#include <boost/system/error_code.hpp>
#include <opm/common/utility/FileSystem.hpp>
namespace {
@ -66,9 +65,9 @@ inline std::string uppercase( std::string x ) {
return x;
}
void ensure_directory_exists( const boost::filesystem::path& odir )
void ensure_directory_exists( const Opm::filesystem::path& odir )
{
namespace fs = boost::filesystem;
namespace fs = Opm::filesystem;
if (fs::exists( odir ) && !fs::is_directory( odir ))
throw std::runtime_error {
@ -76,11 +75,11 @@ void ensure_directory_exists( const boost::filesystem::path& odir )
+ "' already exists but is not a directory"
};
boost::system::error_code ec{};
std::error_code ec{};
if (! fs::exists( odir ))
fs::create_directories( odir, ec );
if (ec != boost::system::errc::success) {
if (ec) {
std::ostringstream msg;
msg << "Failed to create output directory '"
@ -145,7 +144,7 @@ void EclipseIO::Impl::writeEGRIDFile( const NNC& nnc ) {
+ (formatted ? std::string{"F"} : std::string{})
+ "EGRID";
const auto egridFile = (boost::filesystem::path{ this->outputDir }
const auto egridFile = (Opm::filesystem::path{ this->outputDir }
/ (this->baseName + ext)).generic_string();
this->grid.save( egridFile, formatted, nnc, this->es.getDeckUnitSystem());

View File

@ -23,7 +23,7 @@
#include <sstream>
#include <boost/lexical_cast.hpp>
#include <boost/filesystem.hpp>
#include <opm/common/utility/FileSystem.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
@ -60,12 +60,12 @@ namespace Opm {
inline std::string basename( const std::string& path ) {
return boost::filesystem::path( path ).stem().string();
return Opm::filesystem::path( path ).stem().string();
}
inline std::string outputdir( const std::string& path ) {
auto dir = boost::filesystem::path( path ).parent_path().string();
auto dir = Opm::filesystem::path( path ).parent_path().string();
if( dir.empty() ) return default_dir;
@ -266,7 +266,7 @@ namespace Opm {
}
std::string IOConfig::fullBasePath( ) const {
namespace fs = boost::filesystem;
namespace fs = Opm::filesystem;
fs::path dir( m_output_dir );
fs::path base( m_base_name );

View File

@ -17,6 +17,7 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cassert>
#include <ctime>
#include <stddef.h>

View File

@ -23,8 +23,7 @@
#include <stdexcept>
#include <cctype>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <opm/common/utility/FileSystem.hpp>
#include <opm/json/JsonObject.hpp>
#include <opm/parser/eclipse/Generator/KeywordGenerator.hpp>
@ -60,9 +59,9 @@ namespace Opm {
}
void KeywordGenerator::ensurePath( const std::string& file_name) {
boost::filesystem::path file(file_name);
if (!boost::filesystem::is_directory( file.parent_path()))
boost::filesystem::create_directories( file.parent_path());
Opm::filesystem::path file(file_name);
if (!Opm::filesystem::is_directory( file.parent_path()))
Opm::filesystem::create_directories( file.parent_path());
}
void KeywordGenerator::updateFile(const std::stringstream& newContent , const std::string& filename) {
@ -163,7 +162,7 @@ namespace Opm {
stream << R"(
#define BOOST_TEST_MODULE GeneratedKeywordTest
#include <boost/filesystem.hpp>
#include <opm/common/utility/FileSystem.hpp>
#include <boost/test/unit_test.hpp>
#include <memory>
#include <opm/json/JsonObject.hpp>
@ -175,7 +174,7 @@ auto unitSystem = Opm::UnitSystem::newMETRIC();
namespace Opm {
void test_keyword(const ParserKeyword& inline_keyword, const std::string& json_file) {
boost::filesystem::path jsonPath( json_file );
Opm::filesystem::path jsonPath( json_file );
Json::JsonObject jsonConfig( jsonPath );
ParserKeyword json_keyword(jsonConfig);
BOOST_CHECK_EQUAL( json_keyword, inline_keyword);

View File

@ -21,8 +21,7 @@
#include <iostream>
#include <fstream>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <opm/common/utility/FileSystem.hpp>
#include <opm/json/JsonObject.hpp>
#include <opm/parser/eclipse/Generator/KeywordLoader.hpp>
@ -37,13 +36,13 @@ namespace Opm {
if (verbose)
std::cout << "Loading keyword from file: " << keyword_file << std::endl;
boost::filesystem::path path( keyword_file );
Opm::filesystem::path path( keyword_file );
std::unique_ptr<ParserKeyword> parserKeyword;
try {
Json::JsonObject jsonConfig = Json::JsonObject( path );
parserKeyword.reset( new ParserKeyword(jsonConfig) );
boost::filesystem::path abs_path = boost::filesystem::absolute( path );
auto abs_path = Opm::filesystem::absolute( path );
} catch (const std::exception& exc) {
std::cerr << std::endl;
std::cerr << "Failed to create parserkeyword from: " << path.string() << std::endl;

View File

@ -22,7 +22,7 @@
#include <iterator>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <opm/common/utility/FileSystem.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/common/OpmLog/LogUtil.hpp>
@ -300,26 +300,26 @@ inline bool isTerminatedRecordString(const string_view& line) {
}
struct file {
file( boost::filesystem::path p, const std::string& in ) :
file( Opm::filesystem::path p, const std::string& in ) :
input( in ), path( p )
{}
string_view input;
size_t lineNR = 0;
boost::filesystem::path path;
Opm::filesystem::path path;
};
class InputStack : public std::stack< file, std::vector< file > > {
public:
void push( std::string&& input, boost::filesystem::path p = "<memory string>" );
void push( std::string&& input, Opm::filesystem::path p = "<memory string>" );
private:
std::list< std::string > string_storage;
using base = std::stack< file, std::vector< file > >;
};
void InputStack::push( std::string&& input, boost::filesystem::path p ) {
void InputStack::push( std::string&& input, Opm::filesystem::path p ) {
this->string_storage.push_back( std::move( input ) );
this->emplace( p, this->string_storage.back() );
}
@ -327,17 +327,17 @@ void InputStack::push( std::string&& input, boost::filesystem::path p ) {
class ParserState {
public:
ParserState( const std::vector<std::pair<std::string,std::string>>&, const ParseContext&, ErrorGuard& );
ParserState( const std::vector<std::pair<std::string,std::string>>&, const ParseContext&, ErrorGuard&, boost::filesystem::path );
ParserState( const std::vector<std::pair<std::string,std::string>>&, const ParseContext&, ErrorGuard&, Opm::filesystem::path );
void loadString( const std::string& );
void loadFile( const boost::filesystem::path& );
void openRootFile( const boost::filesystem::path& );
void loadFile( const Opm::filesystem::path& );
void openRootFile( const Opm::filesystem::path& );
void handleRandomText(const string_view& ) const;
boost::filesystem::path getIncludeFilePath( std::string ) const;
Opm::filesystem::path getIncludeFilePath( std::string ) const;
void addPathAlias( const std::string& alias, const std::string& path );
const boost::filesystem::path& current_path() const;
const Opm::filesystem::path& current_path() const;
size_t line() const;
bool done() const;
@ -350,7 +350,7 @@ class ParserState {
InputStack input_stack;
std::map< std::string, std::string > pathMap;
boost::filesystem::path rootPath;
Opm::filesystem::path rootPath;
public:
ParserKeywordSizeEnum lastSizeType = SLASH_TERMINATED;
@ -363,7 +363,7 @@ class ParserState {
bool unknown_keyword = false;
};
const boost::filesystem::path& ParserState::current_path() const {
const Opm::filesystem::path& ParserState::current_path() const {
return this->input_stack.top().path;
}
@ -419,9 +419,9 @@ ParserState::ParserState(const std::vector<std::pair<std::string, std::string>>&
ParserState::ParserState( const std::vector<std::pair<std::string, std::string>>& code_keywords_arg,
const ParseContext& context,
ErrorGuard& errors_arg,
boost::filesystem::path p ) :
Opm::filesystem::path p ) :
code_keywords(code_keywords_arg),
rootPath( boost::filesystem::canonical( p ).parent_path() ),
rootPath( Opm::filesystem::canonical( p ).parent_path() ),
python( PythonInstance() ),
parseContext( context ),
errors( errors_arg )
@ -433,12 +433,12 @@ void ParserState::loadString(const std::string& input) {
this->input_stack.push( str::clean( this->code_keywords, input + "\n" ) );
}
void ParserState::loadFile(const boost::filesystem::path& inputFile) {
void ParserState::loadFile(const Opm::filesystem::path& inputFile) {
boost::filesystem::path inputFileCanonical;
Opm::filesystem::path inputFileCanonical;
try {
inputFileCanonical = boost::filesystem::canonical(inputFile);
} catch (const boost::filesystem::filesystem_error& fs_error) {
inputFileCanonical = Opm::filesystem::canonical(inputFile);
} catch (const Opm::filesystem::filesystem_error& fs_error) {
std::string msg = "Could not open file: " + inputFile.string();
parseContext.handleError( ParseContext::PARSE_MISSING_INCLUDE , msg, errors);
return;
@ -517,14 +517,14 @@ void ParserState::handleRandomText(const string_view& keywordString ) const {
parseContext.handleError( errorKey , msg.str(), errors );
}
void ParserState::openRootFile( const boost::filesystem::path& inputFile) {
void ParserState::openRootFile( const Opm::filesystem::path& inputFile) {
this->loadFile( inputFile );
this->deck.setDataFile( inputFile.string() );
const boost::filesystem::path& inputFileCanonical = boost::filesystem::canonical(inputFile);
const Opm::filesystem::path& inputFileCanonical = Opm::filesystem::canonical(inputFile);
rootPath = inputFileCanonical.parent_path();
}
boost::filesystem::path ParserState::getIncludeFilePath( std::string path ) const {
Opm::filesystem::path ParserState::getIncludeFilePath( std::string path ) const {
static const std::string pathKeywordPrefix("$");
static const std::string validPathNameCharacters("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");
@ -545,7 +545,7 @@ boost::filesystem::path ParserState::getIncludeFilePath( std::string path ) cons
OpmLog::warning("Replaced one or more backslash with a slash in an INCLUDE path.");
}
boost::filesystem::path includeFilePath(path);
Opm::filesystem::path includeFilePath(path);
if (includeFilePath.is_relative())
return this->rootPath / includeFilePath;
@ -852,7 +852,7 @@ bool parseState( ParserState& parserState, const Parser& parser ) {
if (rawKeyword->getKeywordName() == Opm::RawConsts::include) {
auto& firstRecord = rawKeyword->getFirstRecord( );
std::string includeFileAsString = readValueToken<std::string>(firstRecord.getItem(0));
boost::filesystem::path includeFile = parserState.getIncludeFilePath( includeFileAsString );
Opm::filesystem::path includeFile = parserState.getIncludeFilePath( includeFileAsString );
parserState.loadFile( includeFile );
continue;
@ -1127,7 +1127,7 @@ std::vector<std::string> Parser::getAllDeckNames () const {
throw std::invalid_argument("Input JSON object is not an array");
}
bool Parser::loadKeywordFromFile(const boost::filesystem::path& configFile) {
bool Parser::loadKeywordFromFile(const Opm::filesystem::path& configFile) {
try {
Json::JsonObject jsonKeyword(configFile);
@ -1140,13 +1140,13 @@ std::vector<std::string> Parser::getAllDeckNames () const {
}
void Parser::loadKeywordsFromDirectory(const boost::filesystem::path& directory, bool recursive) {
if (!boost::filesystem::exists(directory))
void Parser::loadKeywordsFromDirectory(const Opm::filesystem::path& directory, bool recursive) {
if (!Opm::filesystem::exists(directory))
throw std::invalid_argument("Directory: " + directory.string() + " does not exist.");
else {
boost::filesystem::directory_iterator end;
for (boost::filesystem::directory_iterator iter(directory); iter != end; iter++) {
if (boost::filesystem::is_directory(*iter)) {
Opm::filesystem::directory_iterator end;
for (Opm::filesystem::directory_iterator iter(directory); iter != end; iter++) {
if (Opm::filesystem::is_directory(*iter)) {
if (recursive)
loadKeywordsFromDirectory(*iter, recursive);
} else {

View File

@ -22,29 +22,30 @@
#include <string>
#include <boost/filesystem.hpp>
#include <opm/common/utility/FileSystem.hpp>
namespace {
class WorkArea
{
public:
explicit WorkArea(const std::string& subdir = "")
: root_(boost::filesystem::temp_directory_path() /
boost::filesystem::unique_path("wrk-%%%%"))
: root_(Opm::filesystem::temp_directory_path() /
Opm::unique_path("wrk-%%%%"))
, area_(root_)
, orig_(boost::filesystem::current_path())
, orig_(Opm::filesystem::current_path())
{
if (! subdir.empty())
this->area_ /= subdir;
boost::filesystem::create_directories(this->area_);
boost::filesystem::current_path(this->area_);
Opm::filesystem::create_directories(this->area_);
Opm::filesystem::current_path(this->area_);
}
void copyIn(const std::string& filename) const
{
boost::filesystem::copy_file(this->orig_ / filename,
this->area_ / filename);
Opm::filesystem::copy_file(this->orig_ / filename,
this->area_ / filename);
}
std::string currentWorkingDirectory() const
@ -54,18 +55,18 @@ namespace {
void makeSubDir(const std::string& dirname)
{
boost::filesystem::create_directories(this->area_ / dirname);
Opm::filesystem::create_directories(this->area_ / dirname);
}
~WorkArea()
{
boost::filesystem::current_path(this->orig_);
boost::filesystem::remove_all(this->root_);
Opm::filesystem::current_path(this->orig_);
Opm::filesystem::remove_all(this->root_);
}
private:
boost::filesystem::path root_;
boost::filesystem::path area_;
boost::filesystem::path orig_;
Opm::filesystem::path root_;
Opm::filesystem::path area_;
Opm::filesystem::path orig_;
};
} // Anonymous

View File

@ -24,7 +24,7 @@
#include <boost/test/unit_test.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/filesystem/path.hpp>
#include <opm/common/utility/FileSystem.hpp>
#include <opm/json/JsonObject.hpp>
@ -244,7 +244,7 @@ BOOST_AUTO_TEST_CASE(parseJSONObject_testType) {
BOOST_AUTO_TEST_CASE(Parse_fileDoesNotExist_Throws) {
boost::filesystem::path jsonFile("file/does/not/exist");
Opm::filesystem::path jsonFile("file/does/not/exist");
BOOST_CHECK_THROW( Json::JsonObject parser(jsonFile) , std::invalid_argument);
}
@ -252,14 +252,14 @@ BOOST_AUTO_TEST_CASE(Parse_fileDoesNotExist_Throws) {
BOOST_AUTO_TEST_CASE(Parse_fileExists_OK) {
const auto arg = framework::master_test_suite().argv[1];
boost::filesystem::path jsonFile(arg);
Opm::filesystem::path jsonFile(arg);
BOOST_CHECK_NO_THROW( Json::JsonObject parser(jsonFile) );
}
BOOST_AUTO_TEST_CASE(to_string_ok) {
const auto arg = framework::master_test_suite().argv[1];
boost::filesystem::path jsonFile(arg);
Opm::filesystem::path jsonFile(arg);
Json::JsonObject parser(jsonFile);
std::string json_string =
"{\n"

View File

@ -25,7 +25,7 @@
#include <stdexcept>
#include <iostream>
#include <boost/filesystem.hpp>
#include <opm/common/utility/FileSystem.hpp>
#include <opm/io/eclipse/ERst.hpp>
#include <opm/io/eclipse/ESmry.hpp>
@ -59,10 +59,10 @@ void pressure(const EclipseState& es, const Schedule& /* sched */, data::Solutio
std::fill(data.begin(), data.end(), units.to_si(UnitSystem::measure::pressure, seconds_elapsed));
}
bool is_file(const boost::filesystem::path& name)
bool is_file(const Opm::filesystem::path& name)
{
return boost::filesystem::exists(name)
&& boost::filesystem::is_regular_file(name);
return Opm::filesystem::exists(name)
&& Opm::filesystem::is_regular_file(name);
}
}

View File

@ -26,7 +26,7 @@
#include <stdexcept>
#include <unistd.h>
#include <boost/filesystem.hpp>
#include <opm/common/utility/FileSystem.hpp>
#define BOOST_TEST_MODULE EclipseGridTests
#include <boost/test/unit_test.hpp>
@ -1800,14 +1800,14 @@ BOOST_AUTO_TEST_CASE(SAVE_FIELD_UNITS) {
time_t timer;
time(&timer);
std::string cwd = boost::filesystem::current_path().c_str();
std::string cwd = Opm::filesystem::current_path().c_str();
std::string testDir = cwd + "/tmp_dir_" + std::to_string(timer);
if ( boost::filesystem::exists( testDir )) {
boost::filesystem::remove_all(testDir);
if ( Opm::filesystem::exists( testDir )) {
Opm::filesystem::remove_all(testDir);
}
boost::filesystem::create_directory(testDir);
Opm::filesystem::create_directory(testDir);
std::string fileName = testDir + "/" + "TMP.EGRID";
grid1.save(fileName, formatted, nnc, units);
@ -1912,7 +1912,7 @@ BOOST_AUTO_TEST_CASE(SAVE_FIELD_UNITS) {
BOOST_CHECK( ref3_mapaxes[n] == test_mapaxes3[n]);
}
boost::filesystem::remove_all(testDir);
Opm::filesystem::remove_all(testDir);
}
BOOST_AUTO_TEST_CASE(SAVE_METRIC_UNITS) {
@ -1993,14 +1993,14 @@ BOOST_AUTO_TEST_CASE(SAVE_METRIC_UNITS) {
time_t timer;
time(&timer);
std::string cwd = boost::filesystem::current_path().c_str();
std::string cwd = Opm::filesystem::current_path().c_str();
std::string testDir = cwd + "/tmp_dir_" + std::to_string(timer);
if ( boost::filesystem::exists( testDir )) {
boost::filesystem::remove_all(testDir);
if ( Opm::filesystem::exists( testDir )) {
Opm::filesystem::remove_all(testDir);
}
boost::filesystem::create_directory(testDir);
Opm::filesystem::create_directory(testDir);
std::string fileName = testDir + "/" + "TMP.FEGRID";
grid1.save(fileName, formatted, nnc, units1);
@ -2105,7 +2105,7 @@ BOOST_AUTO_TEST_CASE(SAVE_METRIC_UNITS) {
}
boost::filesystem::remove_all(testDir);
Opm::filesystem::remove_all(testDir);
}
BOOST_AUTO_TEST_CASE(CalcCellDims) {

View File

@ -23,6 +23,7 @@
#include <boost/test/unit_test.hpp>
#include <opm/common/utility/FileSystem.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp>
@ -263,7 +264,7 @@ BOOST_AUTO_TEST_CASE(OutputPaths) {
BOOST_CHECK_EQUAL( output_dir2, config2.getOutputDir() );
BOOST_CHECK_EQUAL( "TESTSTRING", config2.getBaseName() );
namespace fs = boost::filesystem;
namespace fs = Opm::filesystem;
Deck deck3;
deck3.setDataFile( "/path/to/testString.DATA" );

View File

@ -19,9 +19,9 @@
#define BOOST_TEST_MODULE ParserTests
#include <boost/filesystem/path.hpp>
#include <boost/test/unit_test.hpp>
#include <opm/common/utility/FileSystem.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
@ -33,7 +33,7 @@ inline std::string prefix() {
BOOST_AUTO_TEST_CASE(ParserKeyword_includeInvalid) {
boost::filesystem::path inputFilePath(prefix() + "includeInvalid.data");
Opm::filesystem::path inputFilePath(prefix() + "includeInvalid.data");
Opm::Parser parser;
Opm::ParseContext parseContext;
@ -48,7 +48,7 @@ BOOST_AUTO_TEST_CASE(ParserKeyword_includeInvalid) {
BOOST_AUTO_TEST_CASE(DATA_FILE_IS_SYMLINK) {
boost::filesystem::path inputFilePath(prefix() + "includeSymlinkTestdata/symlink4/path/case.data");
Opm::filesystem::path inputFilePath(prefix() + "includeSymlinkTestdata/symlink4/path/case.data");
Opm::Parser parser;
std::cout << "Input file: " << inputFilePath.string() << std::endl;
auto deck = parser.parseFile(inputFilePath.string());
@ -59,7 +59,7 @@ BOOST_AUTO_TEST_CASE(DATA_FILE_IS_SYMLINK) {
BOOST_AUTO_TEST_CASE(Verify_find_includes_Data_file_is_a_symlink) {
boost::filesystem::path inputFilePath(prefix() + "includeSymlinkTestdata/symlink1/case_symlink.data");
Opm::filesystem::path inputFilePath(prefix() + "includeSymlinkTestdata/symlink1/case_symlink.data");
Opm::Parser parser;
auto deck = parser.parseFile(inputFilePath.string());
@ -69,7 +69,7 @@ BOOST_AUTO_TEST_CASE(Verify_find_includes_Data_file_is_a_symlink) {
BOOST_AUTO_TEST_CASE(Verify_find_includes_Data_file_has_include_that_is_a_symlink) {
boost::filesystem::path inputFilePath(prefix() + "includeSymlinkTestdata/symlink2/caseWithIncludedSymlink.data");
Opm::filesystem::path inputFilePath(prefix() + "includeSymlinkTestdata/symlink2/caseWithIncludedSymlink.data");
Opm::Parser parser;
auto deck = parser.parseFile(inputFilePath.string());
@ -79,7 +79,7 @@ BOOST_AUTO_TEST_CASE(Verify_find_includes_Data_file_has_include_that_is_a_symlin
BOOST_AUTO_TEST_CASE(Verify_find_includes_Data_file_has_include_file_that_again_includes_a_symlink) {
boost::filesystem::path inputFilePath(prefix() + "includeSymlinkTestdata/symlink3/case.data");
Opm::filesystem::path inputFilePath(prefix() + "includeSymlinkTestdata/symlink3/case.data");
Opm::Parser parser;
auto deck = parser.parseFile(inputFilePath.string());
@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE(Verify_find_includes_Data_file_has_include_file_that_again_
BOOST_AUTO_TEST_CASE(ParserKeyword_includeValid) {
boost::filesystem::path inputFilePath(prefix() + "includeValid.data");
Opm::filesystem::path inputFilePath(prefix() + "includeValid.data");
Opm::Parser parser;
auto deck = parser.parseFile(inputFilePath.string());
@ -104,9 +104,9 @@ BOOST_AUTO_TEST_CASE(ParserKeyword_includeValid) {
BOOST_AUTO_TEST_CASE(ParserKeyword_includeWrongCase) {
boost::filesystem::path inputFile1Path(prefix() + "includeWrongCase1.data");
boost::filesystem::path inputFile2Path(prefix() + "includeWrongCase2.data");
boost::filesystem::path inputFile3Path(prefix() + "includeWrongCase3.data");
Opm::filesystem::path inputFile1Path(prefix() + "includeWrongCase1.data");
Opm::filesystem::path inputFile2Path(prefix() + "includeWrongCase2.data");
Opm::filesystem::path inputFile3Path(prefix() + "includeWrongCase3.data");
Opm::Parser parser;

View File

@ -22,6 +22,7 @@
#include <opm/json/JsonObject.hpp>
#include <opm/common/utility/FileSystem.hpp>
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
@ -187,28 +188,28 @@ BOOST_AUTO_TEST_CASE(loadKeywordsJSON_manyKeywords_returnstrue) {
BOOST_AUTO_TEST_CASE(loadKeywordFromFile_fileDoesNotExist_returnsFalse) {
Parser parser;
boost::filesystem::path configFile("File/does/not/exist");
Opm::filesystem::path configFile("File/does/not/exist");
BOOST_CHECK_EQUAL( false , parser.loadKeywordFromFile( configFile ));
}
BOOST_AUTO_TEST_CASE(loadKeywordFromFile_invalidJson_returnsFalse) {
Parser parser;
boost::filesystem::path configFile(prefix() + "json/example_invalid_json");
Opm::filesystem::path configFile(prefix() + "json/example_invalid_json");
BOOST_CHECK_EQUAL( false , parser.loadKeywordFromFile( configFile ));
}
BOOST_AUTO_TEST_CASE(loadKeywordFromFile_invalidConfig_returnsFalse) {
Parser parser;
boost::filesystem::path configFile(prefix() + "json/example_missing_name.json");
Opm::filesystem::path configFile(prefix() + "json/example_missing_name.json");
BOOST_CHECK_EQUAL( false , parser.loadKeywordFromFile( configFile ));
}
BOOST_AUTO_TEST_CASE(loadKeywordFromFile_validKeyword_returnsTrueHasKeyword) {
Parser parser( false );
boost::filesystem::path configFile(prefix() + "json/BPR");
Opm::filesystem::path configFile(prefix() + "json/BPR");
BOOST_CHECK_EQUAL( true , parser.loadKeywordFromFile( configFile ));
BOOST_CHECK_EQUAL( 1U , parser.size() );
BOOST_CHECK_EQUAL( true , parser.isRecognizedKeyword("BPR") );
@ -218,14 +219,14 @@ BOOST_AUTO_TEST_CASE(loadKeywordFromFile_validKeyword_returnsTrueHasKeyword) {
BOOST_AUTO_TEST_CASE(loadConfigFromDirectory_directoryDoesNotexist_throws) {
Parser parser;
boost::filesystem::path configPath("path/does/not/exist");
Opm::filesystem::path configPath("path/does/not/exist");
BOOST_CHECK_THROW(parser.loadKeywordsFromDirectory( configPath), std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(loadConfigFromDirectory_notRecursive_allNames) {
Parser parser( false );
BOOST_CHECK_EQUAL(false , parser.isRecognizedKeyword("BPR"));
boost::filesystem::path configPath(prefix() + "config/directory1");
Opm::filesystem::path configPath(prefix() + "config/directory1");
BOOST_CHECK_NO_THROW(parser.loadKeywordsFromDirectory( configPath, false));
BOOST_CHECK(parser.isRecognizedKeyword("WWCT"));
BOOST_CHECK_EQUAL(true , parser.isRecognizedKeyword("BPR"));
@ -235,7 +236,7 @@ BOOST_AUTO_TEST_CASE(loadConfigFromDirectory_notRecursive_allNames) {
BOOST_AUTO_TEST_CASE(loadConfigFromDirectory_notRecursive_strictNames) {
Parser parser( false );
boost::filesystem::path configPath(prefix() + "config/directory1");
Opm::filesystem::path configPath(prefix() + "config/directory1");
BOOST_CHECK_NO_THROW(parser.loadKeywordsFromDirectory( configPath, false));
BOOST_CHECK(parser.isRecognizedKeyword("WWCT"));
// the file name for the following keyword is "Bpr", but that
@ -248,7 +249,7 @@ BOOST_AUTO_TEST_CASE(loadConfigFromDirectory_notRecursive_strictNames) {
BOOST_AUTO_TEST_CASE(loadConfigFromDirectory_Recursive_allNames) {
Parser parser( false );
BOOST_CHECK_EQUAL(false , parser.isRecognizedKeyword("BPR"));
boost::filesystem::path configPath(prefix() + "config/directory1");
Opm::filesystem::path configPath(prefix() + "config/directory1");
BOOST_CHECK_NO_THROW(parser.loadKeywordsFromDirectory( configPath, true));
BOOST_CHECK(parser.isRecognizedKeyword("WWCT"));
BOOST_CHECK_EQUAL(true , parser.isRecognizedKeyword("BPR"));
@ -259,7 +260,7 @@ BOOST_AUTO_TEST_CASE(loadConfigFromDirectory_Recursive_allNames) {
BOOST_AUTO_TEST_CASE(loadConfigFromDirectory_default) {
Parser parser( false );
BOOST_CHECK_EQUAL(false , parser.isRecognizedKeyword("BPR"));
boost::filesystem::path configPath(prefix() + "config/directory1");
Opm::filesystem::path configPath(prefix() + "config/directory1");
BOOST_CHECK_NO_THROW(parser.loadKeywordsFromDirectory( configPath ));
BOOST_CHECK(parser.isRecognizedKeyword("WWCT"));
// the file name for the following keyword is "Bpr", but that

View File

@ -40,7 +40,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/filesystem.hpp>
#include <opm/common/utility/FileSystem.hpp>
#include <stdexcept>
#include <iostream>
@ -53,7 +53,7 @@ inline std::string prefix() {
BOOST_AUTO_TEST_CASE( PvtxNumTables1 ) {
Parser parser;
boost::filesystem::path deckFile(prefix() + "TABLES/PVTX1.DATA");
Opm::filesystem::path deckFile(prefix() + "TABLES/PVTX1.DATA");
auto deck = parser.parseFile(deckFile.string());
BOOST_CHECK_EQUAL( PvtxTable::numTables( deck.getKeyword<ParserKeywords::PVTO>()) , 1);
@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE( PvtxNumTables1 ) {
BOOST_AUTO_TEST_CASE( PvtxNumTables2 ) {
Parser parser;
boost::filesystem::path deckFile(prefix() + "TABLES/PVTO2.DATA");
Opm::filesystem::path deckFile(prefix() + "TABLES/PVTO2.DATA");
auto deck = parser.parseFile(deckFile.string());
BOOST_CHECK_EQUAL( PvtxTable::numTables( deck.getKeyword<ParserKeywords::PVTO>()) , 3);
@ -118,7 +118,7 @@ BOOST_AUTO_TEST_CASE( PvtxNumTables3 ) {
BOOST_AUTO_TEST_CASE( PVTOSaturatedTable ) {
Parser parser;
boost::filesystem::path deckFile(prefix() + "TABLES/PVTX1.DATA");
Opm::filesystem::path deckFile(prefix() + "TABLES/PVTX1.DATA");
auto deck = parser.parseFile(deckFile.string());
Opm::TableManager tables(deck);
const auto& pvtoTables = tables.getPvtoTables( );
@ -164,7 +164,7 @@ BOOST_AUTO_TEST_CASE( PVTOSaturatedTable ) {
BOOST_AUTO_TEST_CASE( PVTGSaturatedTable ) {
Parser parser;
boost::filesystem::path deckFile(prefix() + "TABLES/PVTX1.DATA");
Opm::filesystem::path deckFile(prefix() + "TABLES/PVTX1.DATA");
auto deck = parser.parseFile(deckFile.string());
Opm::TableManager tables(deck);
const auto& pvtgTables = tables.getPvtgTables( );

View File

@ -22,7 +22,7 @@
#include <boost/test/unit_test.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/filesystem/path.hpp>
#include <opm/common/utility/FileSystem.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
@ -38,7 +38,7 @@ inline std::string prefix() {
inline Deck makeDeck(const std::string& fileName) {
Parser parser;
boost::filesystem::path boxFile(fileName);
Opm::filesystem::path boxFile(fileName);
return parser.parseFile(boxFile.string());
}

View File

@ -23,7 +23,8 @@
#include <boost/test/unit_test.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/filesystem/path.hpp>
#include <opm/common/utility/FileSystem.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
@ -40,7 +41,7 @@ inline std::string prefix() {
BOOST_AUTO_TEST_CASE(CreateCPGrid) {
Parser parser;
boost::filesystem::path scheduleFile(prefix() + "GRID/CORNERPOINT.DATA");
Opm::filesystem::path scheduleFile(prefix() + "GRID/CORNERPOINT.DATA");
auto deck = parser.parseFile(scheduleFile.string());
EclipseState es(deck);
const auto& grid = es.getInputGrid();
@ -54,7 +55,7 @@ BOOST_AUTO_TEST_CASE(CreateCPGrid) {
BOOST_AUTO_TEST_CASE(CreateCPActnumGrid) {
Parser parser;
boost::filesystem::path scheduleFile(prefix() + "GRID/CORNERPOINT_ACTNUM.DATA");
Opm::filesystem::path scheduleFile(prefix() + "GRID/CORNERPOINT_ACTNUM.DATA");
auto deck = parser.parseFile(scheduleFile.string());
EclipseState es(deck);
const auto& grid = es.getInputGrid();
@ -68,7 +69,7 @@ BOOST_AUTO_TEST_CASE(CreateCPActnumGrid) {
BOOST_AUTO_TEST_CASE(ExportFromCPGridAllActive) {
Parser parser;
boost::filesystem::path scheduleFile(prefix() + "GRID/CORNERPOINT.DATA");
Opm::filesystem::path scheduleFile(prefix() + "GRID/CORNERPOINT.DATA");
auto deck = parser.parseFile(scheduleFile.string());
EclipseState es(deck);
const auto& grid = es.getInputGrid();
@ -84,7 +85,7 @@ BOOST_AUTO_TEST_CASE(ExportFromCPGridAllActive) {
BOOST_AUTO_TEST_CASE(ExportFromCPGridACTNUM) {
Parser parser;
boost::filesystem::path scheduleFile(prefix() + "GRID/CORNERPOINT_ACTNUM.DATA");
Opm::filesystem::path scheduleFile(prefix() + "GRID/CORNERPOINT_ACTNUM.DATA");
auto deck = parser.parseFile(scheduleFile.string());
EclipseState es(deck);
auto& grid = es.getInputGrid();

View File

@ -20,7 +20,7 @@
#define BOOST_TEST_MODULE ParserIntegrationTests
#include <boost/test/unit_test.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/filesystem.hpp>
#include <opm/common/utility/FileSystem.hpp>
#include <ostream>
#include <fstream>
@ -32,7 +32,7 @@
#include <opm/parser/eclipse/Parser/ParserEnums.hpp>
using namespace Opm;
using namespace boost::filesystem;
using namespace Opm::filesystem;
static void
createDeckWithInclude(path& datafile, std::string addEndKeyword)

View File

@ -20,7 +20,7 @@
#define BOOST_TEST_MODULE ParserIntegrationTests
#include <boost/test/unit_test.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/filesystem/path.hpp>
#include <opm/common/utility/FileSystem.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
@ -72,7 +72,7 @@ Parser createWWCTParser() {
}
BOOST_AUTO_TEST_CASE(parse_fileWithWWCTKeyword_deckReturned) {
boost::filesystem::path singleKeywordFile(pathprefix() + "wwct.data");
Opm::filesystem::path singleKeywordFile(pathprefix() + "wwct.data");
auto parser = createWWCTParser();
BOOST_CHECK( parser.isRecognizedKeyword("WWCT"));
BOOST_CHECK( parser.isRecognizedKeyword("SUMMARY"));
@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE(parse_streamWithWWCTKeyword_deckReturned) {
}
BOOST_AUTO_TEST_CASE(parse_fileWithWWCTKeyword_deckHasWWCT) {
boost::filesystem::path singleKeywordFile(pathprefix() + "wwct.data");
Opm::filesystem::path singleKeywordFile(pathprefix() + "wwct.data");
auto parser = createWWCTParser();
auto deck = parser.parseFile(singleKeywordFile.string());
BOOST_CHECK(deck.hasKeyword("SUMMARY"));
@ -116,7 +116,7 @@ BOOST_AUTO_TEST_CASE(parse_fileWithWWCTKeyword_deckHasWWCT) {
}
BOOST_AUTO_TEST_CASE(parse_fileWithWWCTKeyword_dataIsCorrect) {
boost::filesystem::path singleKeywordFile(pathprefix() + "wwct.data");
Opm::filesystem::path singleKeywordFile(pathprefix() + "wwct.data");
auto parser = createWWCTParser();
auto deck = parser.parseFile(singleKeywordFile.string());
BOOST_CHECK_EQUAL("WELL-1", deck.getKeyword("WWCT" , 0).getRecord(0).getItem(0).get< std::string >(0));
@ -157,14 +157,14 @@ static Parser createBPRParser() {
}
BOOST_AUTO_TEST_CASE(parse_fileWithBPRKeyword_deckReturned) {
boost::filesystem::path singleKeywordFile(pathprefix() + "bpr.data");
Opm::filesystem::path singleKeywordFile(pathprefix() + "bpr.data");
auto parser = createBPRParser();
BOOST_CHECK_NO_THROW(parser.parseFile(singleKeywordFile.string()));
}
BOOST_AUTO_TEST_CASE(parse_fileWithBPRKeyword_DeckhasBRP) {
boost::filesystem::path singleKeywordFile(pathprefix() + "bpr.data");
Opm::filesystem::path singleKeywordFile(pathprefix() + "bpr.data");
auto parser = createBPRParser();
auto deck = parser.parseFile(singleKeywordFile.string());
@ -173,7 +173,7 @@ BOOST_AUTO_TEST_CASE(parse_fileWithBPRKeyword_DeckhasBRP) {
}
BOOST_AUTO_TEST_CASE(parse_fileWithBPRKeyword_dataiscorrect) {
boost::filesystem::path singleKeywordFile(pathprefix() + "bpr.data");
Opm::filesystem::path singleKeywordFile(pathprefix() + "bpr.data");
auto parser = createBPRParser();
auto deck = parser.parseFile(singleKeywordFile.string());

View File

@ -32,12 +32,13 @@
#include <iostream>
#include <iterator>
#include <math.h>
#include <random>
#include <stdio.h>
#include <tuple>
#include <type_traits>
#include<numeric>
#include <boost/filesystem.hpp>
#include <opm/common/utility/FileSystem.hpp>
using namespace Opm::EclIO;
@ -312,21 +313,20 @@ BOOST_AUTO_TEST_CASE(TestERst_4) {
// ====================================================================
class RSet
{
public:
explicit RSet(std::string base)
: odir_(boost::filesystem::temp_directory_path() /
boost::filesystem::unique_path("rset-%%%%"))
: odir_(Opm::filesystem::temp_directory_path() /
Opm::unique_path("rset-%%%%"))
, base_(std::move(base))
{
boost::filesystem::create_directories(this->odir_);
Opm::filesystem::create_directories(this->odir_);
}
~RSet()
{
boost::filesystem::remove_all(this->odir_);
Opm::filesystem::remove_all(this->odir_);
}
operator ::Opm::EclIO::OutputStream::ResultSet() const
@ -335,7 +335,7 @@ public:
}
private:
boost::filesystem::path odir_;
Opm::filesystem::path odir_;
std::string base_;
};

View File

@ -41,7 +41,7 @@
#include <utility>
#include <vector>
#include <boost/filesystem.hpp>
#include <opm/common/utility/FileSystem.hpp>
namespace Opm { namespace EclIO {
@ -129,21 +129,20 @@ BOOST_AUTO_TEST_CASE(ResultSetDescriptor)
BOOST_AUTO_TEST_SUITE_END() // FileName
// ==========================================================================
class RSet
{
public:
explicit RSet(std::string base)
: odir_(boost::filesystem::temp_directory_path() /
boost::filesystem::unique_path("rset-%%%%"))
: odir_(Opm::filesystem::temp_directory_path() /
Opm::unique_path("rset-%%%%"))
, base_(std::move(base))
{
boost::filesystem::create_directories(this->odir_);
Opm::filesystem::create_directories(this->odir_);
}
~RSet()
{
boost::filesystem::remove_all(this->odir_);
Opm::filesystem::remove_all(this->odir_);
}
operator ::Opm::EclIO::OutputStream::ResultSet() const
@ -152,7 +151,7 @@ public:
}
private:
boost::filesystem::path odir_;
Opm::filesystem::path odir_;
std::string base_;
};

View File

@ -55,7 +55,7 @@
#include <vector>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/filesystem.hpp>
#include <opm/common/utility/FileSystem.hpp>
using namespace Opm;
@ -76,16 +76,16 @@ namespace {
{
public:
explicit RSet(std::string base)
: odir_(boost::filesystem::temp_directory_path() /
boost::filesystem::unique_path("rset-%%%%"))
: odir_(Opm::filesystem::temp_directory_path() /
Opm::unique_path("rset-%%%%"))
, base_(std::move(base))
{
boost::filesystem::create_directories(this->odir_);
Opm::filesystem::create_directories(this->odir_);
}
~RSet()
{
boost::filesystem::remove_all(this->odir_);
Opm::filesystem::remove_all(this->odir_);
}
std::string outputDir() const
@ -99,7 +99,7 @@ namespace {
}
private:
boost::filesystem::path odir_;
Opm::filesystem::path odir_;
std::string base_;
};