Simplified deck filename handling. Only set filename if successfully opened

This commit is contained in:
Kjell W. Kongsvik 2016-04-28 15:42:07 +02:00
parent 79ab818c3a
commit b3b8cebeff
5 changed files with 8 additions and 16 deletions

View File

@ -123,13 +123,13 @@ namespace Opm {
Deck::Deck() :
Deck( std::vector< DeckKeyword >() )
{
m_hasDataFile = false;
m_dataFile = "";
}
Deck::Deck( std::vector< DeckKeyword >&& x ) :
DeckView( x.begin(), x.end() ),
keywordList( std::move( x ) ),
m_hasDataFile(false)
m_dataFile("")
{}
void Deck::addKeyword( DeckKeyword&& keyword ) {
@ -200,12 +200,7 @@ namespace Opm {
}
void Deck::setDataFile(const std::string& dataFile) {
m_hasDataFile = true;
m_dataFile = dataFile;
}
bool Deck::hasDataFile() const {
return m_hasDataFile;
}
}

View File

@ -117,7 +117,6 @@ namespace Opm {
const std::string getDataFile() const;
void setDataFile(const std::string& dataFile);
bool hasDataFile() const;
private:
Deck( std::vector< DeckKeyword >&& );
@ -132,7 +131,6 @@ namespace Opm {
mutable std::unique_ptr< UnitSystem > defaultUnits;
std::string m_dataFile;
bool m_hasDataFile;
};
typedef std::shared_ptr<Deck> DeckPtr;

View File

@ -155,7 +155,7 @@ BOOST_AUTO_TEST_CASE(keywordList_getbyindex_correctkeywordreturned) {
BOOST_AUTO_TEST_CASE(set_and_get_data_file) {
Deck deck;
BOOST_REQUIRE(!deck.hasDataFile());
BOOST_CHECK_EQUAL("", deck.getDataFile());
std::string file("/path/to/file.DATA");
deck.setDataFile( file );
BOOST_CHECK_EQUAL(file, deck.getDataFile());

View File

@ -161,11 +161,9 @@ namespace Opm {
}
void EclipseState::initIOConfig(DeckConstPtr deck) {
std::string df = "";
if (deck->hasDataFile()) {
df = deck->getDataFile();
}
m_ioConfig = std::make_shared<IOConfig>(df);
std::string dataFile = deck->getDataFile();
m_ioConfig = std::make_shared<IOConfig>(dataFile);
if (Section::hasGRID(*deck)) {
std::shared_ptr<const GRIDSection> gridSection = std::make_shared<const GRIDSection>(*deck);
m_ioConfig->handleGridSection(gridSection);

View File

@ -117,6 +117,8 @@ namespace Opm {
void openRootFile( const boost::filesystem::path& inputFile) {
openFile( inputFile );
deck->setDataFile(dataFile.string());
const boost::filesystem::path& inputFileCanonical = boost::filesystem::canonical(inputFile);
rootPath = inputFileCanonical.parent_path();
}
@ -229,7 +231,6 @@ namespace Opm {
parserState->openRootFile( dataFileName );
parseState(parserState);
applyUnitsToDeck(*parserState->deck);
parserState->deck->setDataFile(dataFileName);
return parserState->deck;
}