| 240 | } |
| 241 | |
| 242 | boost::optional<EpwFile> WeatherFile_Impl::file(const openstudio::path& dir) const { |
| 243 | boost::optional<EpwFile> result; |
| 244 | |
| 245 | // get current path |
| 246 | boost::optional<openstudio::path> currentPath = this->path(); |
| 247 | if (currentPath) { |
| 248 | |
| 249 | // try to load absolute path |
| 250 | if (currentPath->is_complete() && openstudio::filesystem::exists(*currentPath)) { |
| 251 | try { |
| 252 | result = EpwFile(*currentPath); |
| 253 | return result; |
| 254 | } catch (...) { |
| 255 | } |
| 256 | |
| 257 | // loading absolute path failed, try as relative path |
| 258 | currentPath = currentPath->filename(); |
| 259 | } |
| 260 | |
| 261 | // try relative path |
| 262 | if (!dir.empty()) { |
| 263 | openstudio::path newPath = openstudio::filesystem::complete(*currentPath, dir); |
| 264 | if (openstudio::filesystem::exists(newPath)) { |
| 265 | try { |
| 266 | result = EpwFile(newPath); |
| 267 | return result; |
| 268 | } catch (...) { |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | return boost::none; |
| 275 | } |
| 276 | |
| 277 | bool WeatherFile_Impl::makeUrlRelative(const openstudio::path& basePath) { |
| 278 | boost::optional<openstudio::path> currentPath = this->path(); |