MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / makeVersioningCallbacks

Method makeVersioningCallbacks

source/game/StarVersioningDatabase.cpp:196–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196LuaCallbacks VersioningDatabase::makeVersioningCallbacks() const {
197 LuaCallbacks versioningCallbacks;
198
199 versioningCallbacks.registerCallback("loadVersionedJson", [this](String const& storagePath) {
200 try {
201 auto& root = Root::singleton();
202 String filePath = File::fullPath(root.toStoragePath(storagePath));
203 String basePath = File::fullPath(root.toStoragePath("."));
204 if (!filePath.beginsWith(basePath))
205 throw VersioningDatabaseException::format(
206 "Cannot load external VersionedJson outside of the Root storage path");
207 auto loadedJson = VersionedJson::readFile(filePath);
208 return updateVersionedJson(loadedJson).content;
209 } catch (IOException const& e) {
210 Logger::debug(
211 "Unable to load versioned JSON file {} in versioning script: {}", storagePath, outputException(e, false));
212 return Json();
213 }
214 });
215
216 return versioningCallbacks;
217}
218
219}

Callers

nothing calls this directly

Calls 7

singletonClass · 0.85
JsonClass · 0.85
toStoragePathMethod · 0.80
formatFunction · 0.50
outputExceptionFunction · 0.50
registerCallbackMethod · 0.45
beginsWithMethod · 0.45

Tested by

no test coverage detected