MCPcopy Create free account
hub / github.com/christophhart/HISE / loadDataFile

Method loadDataFile

hi_scripting/scripting/api/ScriptExpansion.cpp:1558–1597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1556}
1557
1558var ScriptExpansionReference::loadDataFile(var relativePath)
1559{
1560 if (objectExists())
1561 {
1562 if (exp->getExpansionType() == Expansion::FileBased)
1563 {
1564 auto fileToLoad = exp->getSubDirectory(FileHandlerBase::AdditionalSourceCode).getChildFile(relativePath.toString());
1565
1566 if(fileToLoad.existsAsFile())
1567 return JSON::parse(fileToLoad.loadFileAsString());
1568 }
1569 else
1570 {
1571 String rs;
1572
1573 auto wc = exp->getWildcard();
1574 auto path = relativePath.toString();
1575
1576 if (!path.contains(wc))
1577 rs << wc;
1578
1579 rs << path;
1580
1581 PoolReference ref(getScriptProcessor()->getMainController_(), rs, FileHandlerBase::AdditionalSourceCode);
1582
1583 if (auto o = exp->pool->getAdditionalDataPool().loadFromReference(ref, PoolHelpers::LoadAndCacheStrong))
1584 {
1585 var obj;
1586 auto ok = JSON::parse(o->data.getFile(), obj);
1587
1588 if (ok.wasOk())
1589 return obj;
1590
1591 reportScriptError("Error at parsing JSON: " + ok.getErrorMessage());
1592 }
1593 }
1594 }
1595
1596 return {};
1597}
1598
1599String ScriptExpansionReference::getWildcardReference(var relativePath)
1600{

Callers

nothing calls this directly

Calls 14

loadFileAsStringMethod · 0.80
getMainController_Method · 0.80
loadFromReferenceMethod · 0.80
parseFunction · 0.50
getExpansionTypeMethod · 0.45
getChildFileMethod · 0.45
getSubDirectoryMethod · 0.45
toStringMethod · 0.45
existsAsFileMethod · 0.45
getWildcardMethod · 0.45
containsMethod · 0.45
getFileMethod · 0.45

Tested by

no test coverage detected