| 151 | } |
| 152 | |
| 153 | bool initializeModelTempDir(const openstudio::path& osmPath, const openstudio::path& modelTempDir) { |
| 154 | bool result = true; |
| 155 | |
| 156 | if (osmPath.empty() || !openstudio::filesystem::exists(osmPath)) { |
| 157 | |
| 158 | LOG_FREE(Debug, "initializeModelTempDir", "OSM path '" << toString(osmPath) << "' is empty or does not exist"); |
| 159 | result = false; |
| 160 | |
| 161 | } else { |
| 162 | openstudio::path fileName = osmPath.filename(); |
| 163 | openstudio::path destination = modelTempDir / fileName; |
| 164 | LOG_FREE(Debug, "initializeModelTempDir", "Copying '" << toString(osmPath) << "' to '" << toString(destination) << "'"); |
| 165 | |
| 166 | // copy osm file |
| 167 | bool test = true; |
| 168 | try { |
| 169 | openstudio::filesystem::copy_file(osmPath, destination); |
| 170 | test = true; |
| 171 | } catch (const std::exception& e) { |
| 172 | LOG_FREE(Error, "initializeModelTempDir", |
| 173 | "Could not copy osm from '" << toString(osmPath) << "' to '" << toString(destination) << "' error" << e.what()); |
| 174 | test = false; |
| 175 | } |
| 176 | |
| 177 | // Copy all files from existing resources dir into temp dir when opening |
| 178 | openstudio::path sourceDir = getCompanionFolder(osmPath); |
| 179 | openstudio::path destDir = modelTempDir / toPath("resources"); |
| 180 | if (openstudio::filesystem::exists(sourceDir)) { |
| 181 | LOG_FREE(Debug, "initializeModelTempDir", "Copying '" << toString(sourceDir) << "' to '" << toString(destDir) << "'"); |
| 182 | |
| 183 | test = replaceDir(sourceDir, destDir); |
| 184 | if (!test) { |
| 185 | LOG_FREE(Error, "initializeModelTempDir", "Could not copy '" << toString(sourceDir) << "' to '" << toString(destDir) << "'"); |
| 186 | result = false; |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | return result; |
| 192 | } |
| 193 | |
| 194 | bool updateModelTempDir(openstudio::model::Model& /*model*/, const openstudio::path& modelTempDir) { |
| 195 | bool modified = false; |
no test coverage detected