MCPcopy Create free account
hub / github.com/OSVR/OSVR-Core / loadFromFile

Function loadFromFile

src/osvr/Server/JSONResolvePossibleRef.cpp:56–70  ·  view source on GitHub ↗

@brief Helper function to load a JSON file by name in a search path. @return Json::nullValue if could not load, otherwise parsed contents of file.

Source from the content-addressed store, hash-verified

54 /// @return Json::nullValue if could not load, otherwise parsed contents of
55 /// file.
56 static inline Json::Value
57 loadFromFile(std::string fn, std::vector<std::string> const &searchPath) {
58 Json::Value ret{Json::nullValue};
59 for (auto const &path : searchPath) {
60 auto fullFn = boost::filesystem::path(path) / fn;
61 ret = attemptLoad(fullFn.string());
62 if (!ret.isNull()) {
63 return ret;
64 }
65 }
66 // Last ditch effort, or only attempt if no search path provided
67 // This effectively uses the current working directory.
68 ret = attemptLoad(fn);
69 return ret;
70 }
71
72 Json::Value resolvePossibleRef(Json::Value const &input,
73 bool stringAcceptableResult,

Callers 1

resolvePossibleRefFunction · 0.85

Calls 1

attemptLoadFunction · 0.85

Tested by

no test coverage detected