boost::optional<EpwFile> WeatherFile_Impl::file(const openstudio::path& dir) const { boost::optional<EpwFile> result; // get current path boost::optional<openstudio::path> currentPath = this->path(); if (currentPath){ // try to load absolute path if (currentPath->is_complete() && boost::filesystem::exists(*currentPath)) { try { result = EpwFile(*currentPath); return result; }catch (...) {} // loading absolute path failed, try as relative path currentPath = toPath(currentPath->filename()); } // try relative path if (!dir.empty()){ openstudio::path newPath = boost::filesystem::complete(*currentPath, dir); if (boost::filesystem::exists(newPath)) { try { result = EpwFile(newPath); return result; }catch (...) {} } } } return boost::none; }
boost::optional<openstudio::EpwFile> OSRunner::lastEpwFile() const { if (m_lastEpwFile) { return m_lastEpwFile; } if (m_lastEpwFilePath) { try { m_lastEpwFile = EpwFile(*m_lastEpwFilePath); } catch(const std::exception&) { } } return m_lastEpwFile; }