Skip to content

Commit

Permalink
Updates for externalfile and new ft tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-robertson committed Oct 26, 2023
1 parent 3001627 commit 4cc1a59
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/energyplus/Test/ScheduleInterval_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1886,6 +1886,7 @@ TEST_F(EnergyPlusFixture, ScheduleFileRelativePath) {

boost::optional<std::string> fileName = objects[0].getString(2); // File Name
ASSERT_TRUE(fileName);
EXPECT_FALSE(toPath(fileName.get()).is_relative()); // abs path
EXPECT_EQ(externalfile.filePath(), fileName.get()); // abs path
}

Expand Down Expand Up @@ -1918,6 +1919,7 @@ TEST_F(EnergyPlusFixture, ScheduleFileRelativePath) {

boost::optional<std::string> fileName = objects[0].getString(2); // File Name
ASSERT_TRUE(fileName);
EXPECT_FALSE(toPath(fileName.get()).is_relative()); // abs path
EXPECT_EQ(externalfile.filePath(), fileName.get()); // abs path
}

Expand Down Expand Up @@ -1948,6 +1950,7 @@ TEST_F(EnergyPlusFixture, ScheduleFileRelativePath) {

boost::optional<std::string> fileName = objects[0].getString(2); // File Name
ASSERT_TRUE(fileName);
EXPECT_FALSE(toPath(fileName.get()).is_relative()); // abs path
EXPECT_EQ(externalfile.filePath(), fileName.get()); // abs path
}

Expand Down Expand Up @@ -1978,6 +1981,7 @@ TEST_F(EnergyPlusFixture, ScheduleFileRelativePath) {

boost::optional<std::string> fileName = objects[0].getString(2); // File Name
ASSERT_TRUE(fileName);
EXPECT_TRUE(toPath(fileName.get()).is_relative()); // rel path
EXPECT_EQ(externalfile.filePath(), fileName.get()); // rel path
}
}
18 changes: 8 additions & 10 deletions src/model/ExternalFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace model {
path ExternalFile_Impl::filePath() const {
path result;
path fname = toPath(fileName());
if (openstudio::filesystem::is_regular_file(fname)) {
if (openstudio::filesystem::is_regular_file(fname) || fname.is_relative()) {
return fname;
}
std::vector<path> absoluteFilePaths = this->model().workflowJSON().absoluteFilePaths();
Expand Down Expand Up @@ -220,17 +220,15 @@ namespace model {

// we expect all strings to be UTF-8 encoded
path p = toPath(filename);
if (copyFile || !p.is_relative()) {
if (!exists(p)) {
boost::optional<path> op = workflow.findFile(filename);
if (!op) {
this->remove();
LOG_AND_THROW("Cannot find file \"" << filename << "\" for " << this->briefDescription());
}
p = op.get();
if (!exists(p)) {
boost::optional<path> op = workflow.findFile(filename);
if (!op) {
this->remove();
LOG_AND_THROW("Cannot find file \"" << filename << "\" for " << this->briefDescription());
}
OS_ASSERT(exists(p));
p = op.get();
}
OS_ASSERT(exists(p));

bool ok;
if (copyFile) {
Expand Down

0 comments on commit 4cc1a59

Please sign in to comment.