MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / completePathToFile

Function completePathToFile

src/utilities/core/PathHelpers.cpp:61–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61path completePathToFile(const path& p, const path& base, const std::string& ext, bool warnOnMismatch) {
62 path result(p);
63
64 // handle file extension
65 if (!ext.empty()) {
66 result = setFileExtension(p, ext, false, warnOnMismatch);
67 if (result.empty()) {
68 result = p;
69 }
70 }
71
72 // complete path
73 if (!result.is_complete()) {
74 try {
75 if (!base.empty()) {
76 result = openstudio::filesystem::complete(result, base);
77 } else {
78 result = openstudio::filesystem::complete(result);
79 }
80 } catch (...) {
81 LOG_FREE(Info, "openstudio.completePathToFile", "Unable to compete path '" << toString(p) << "'. Returning an empty path.");
82 return {};
83 }
84 }
85
86 // check that result is a file
87 if (!openstudio::filesystem::is_regular_file(result)) {
88 LOG_FREE(Info, "openstudio.completePathToFile",
89 "Path '" << toString(p) << "' could not be resolved to an existing file. Returning an empty path.");
90 return {};
91 }
92
93 return result;
94}
95
96std::string getFileExtension(const path& p) {
97 std::string pext = openstudio::filesystem::extension(p);

Callers 10

loadMethod · 0.85
loadVersionOnlyMethod · 0.85
saveMethod · 0.85
loadMethod · 0.85
saveMethod · 0.85
loadMethod · 0.85
saveMethod · 0.85
TEST_FFunction · 0.85
loadModelMethod · 0.85
loadComponentMethod · 0.85

Calls 3

setFileExtensionFunction · 0.85
toStringFunction · 0.70
emptyMethod · 0.45

Tested by 1

TEST_FFunction · 0.68