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

Method addFileContentToValueTree

hi_scripting/scripting/ScriptProcessor.cpp:730–765  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

728}
729
730void FileChangeListener::addFileContentToValueTree(JavascriptProcessor* jp, ValueTree externalScriptFiles, File scriptFile, ModulatorSynthChain* chainToExport)
731{
732 String fileName = scriptFile.getRelativePathFrom(GET_PROJECT_HANDLER(chainToExport).getSubDirectory(ProjectHandler::SubDirectories::Scripts));
733
734 File globalScriptFolder = PresetHandler::getGlobalScriptFolder(chainToExport);
735
736 if (globalScriptFolder.isDirectory() && scriptFile.isAChildOf(globalScriptFolder))
737 {
738 fileName = "{GLOBAL_SCRIPT_FOLDER}" + scriptFile.getRelativePathFrom(globalScriptFolder);
739 }
740
741 // Wow, much cross-platform, very OSX, totally Windows
742 fileName = fileName.replace("\\", "/");
743
744 for (int j = 0; j < externalScriptFiles.getNumChildren(); j++)
745 {
746 if (externalScriptFiles.getChild(j).getProperty("FileName").toString() == fileName)
747 {
748 return;
749 }
750 }
751
752
753 String fileContent = scriptFile.loadFileAsString();
754
755 auto ok = jp->getScriptEngine()->preprocessor->process(fileContent, fileName);
756
757 jassert(ok.wasOk());
758
759 ValueTree script("Script");
760
761 script.setProperty("FileName", fileName, nullptr);
762 script.setProperty("Content", fileContent, nullptr);
763
764 externalScriptFiles.addChild(script, -1, nullptr);
765}
766
767JavascriptProcessor::ScopedPreprocessorMerger::ScopedPreprocessorMerger(MainController* mc)
768{

Callers

nothing calls this directly

Calls 15

isAChildOfMethod · 0.80
loadFileAsStringMethod · 0.80
getScriptEngineMethod · 0.80
getRelativePathFromMethod · 0.45
getSubDirectoryMethod · 0.45
isDirectoryMethod · 0.45
replaceMethod · 0.45
getNumChildrenMethod · 0.45
toStringMethod · 0.45
getPropertyMethod · 0.45
getChildMethod · 0.45
processMethod · 0.45

Tested by

no test coverage detected