Add function Deck::makeDeckPath()
This commit is contained in:
@@ -147,6 +147,7 @@ namespace Opm {
|
||||
const std::string& getInputPath() const;
|
||||
const std::string& getDataFile() const;
|
||||
void setDataFile(const std::string& dataFile);
|
||||
std::string makeDeckPath(const std::string& path) const;
|
||||
|
||||
iterator begin();
|
||||
iterator end();
|
||||
|
||||
@@ -217,6 +217,17 @@ namespace Opm {
|
||||
return this->input_path;
|
||||
}
|
||||
|
||||
std::string Deck::makeDeckPath(const std::string& path) const {
|
||||
if (path.size() > 0 && path[0] == '/')
|
||||
return path;
|
||||
|
||||
if (this->input_path.size() == 0)
|
||||
return path;
|
||||
else
|
||||
return this->input_path + "/" + path;
|
||||
}
|
||||
|
||||
|
||||
void Deck::setDataFile(const std::string& dataFile) {
|
||||
this->m_dataFile = dataFile;
|
||||
|
||||
|
||||
@@ -167,10 +167,15 @@ BOOST_AUTO_TEST_CASE(set_and_get_data_file) {
|
||||
Deck deck;
|
||||
BOOST_CHECK_EQUAL("", deck.getDataFile());
|
||||
BOOST_CHECK_EQUAL("", deck.getInputPath());
|
||||
BOOST_CHECK_EQUAL("some/path", deck.makeDeckPath("some/path"));
|
||||
BOOST_CHECK_EQUAL("/abs/path", deck.makeDeckPath("/abs/path"));
|
||||
|
||||
std::string file("/path/to/file.DATA");
|
||||
deck.setDataFile( file );
|
||||
BOOST_CHECK_EQUAL(file, deck.getDataFile());
|
||||
BOOST_CHECK_EQUAL("/path/to", deck.getInputPath());
|
||||
BOOST_CHECK_EQUAL("/path/to/some/path", deck.makeDeckPath("some/path"));
|
||||
BOOST_CHECK_EQUAL("/abs/path", deck.makeDeckPath("/abs/path"));
|
||||
|
||||
deck.setDataFile("FILE");
|
||||
BOOST_CHECK_EQUAL("FILE", deck.getDataFile());
|
||||
|
||||
Reference in New Issue
Block a user