| 1196 | } |
| 1197 | |
| 1198 | shared_ptr<Assets::AssetData> Assets::loadJson(AssetPath const& path) const { |
| 1199 | Json json; |
| 1200 | |
| 1201 | if (path.subPath) { |
| 1202 | auto topJson = |
| 1203 | as<JsonData>(loadAsset(AssetId{AssetType::Json, {path.basePath, {}, {}}})); |
| 1204 | if (!topJson) |
| 1205 | return {}; |
| 1206 | |
| 1207 | try { |
| 1208 | auto newData = make_shared<JsonData>(); |
| 1209 | newData->json = topJson->json.query(*path.subPath); |
| 1210 | return newData; |
| 1211 | } catch (StarException const& e) { |
| 1212 | throw AssetException(strf("Could not read JSON value {}", path), e); |
| 1213 | } |
| 1214 | } else { |
| 1215 | return unlockDuring([&]() { |
| 1216 | try { |
| 1217 | auto newData = make_shared<JsonData>(); |
| 1218 | newData->json = readJson(path.basePath); |
| 1219 | return newData; |
| 1220 | } catch (StarException const& e) { |
| 1221 | throw AssetException(strf("Could not read JSON asset {}", path), e); |
| 1222 | } |
| 1223 | }); |
| 1224 | } |
| 1225 | } |
| 1226 | |
| 1227 | shared_ptr<Assets::AssetData> Assets::loadImage(AssetPath const& path) const { |
| 1228 | validatePath(path, true, true); |
no test coverage detected