| 728 | } |
| 729 | |
| 730 | void 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 | |
| 767 | JavascriptProcessor::ScopedPreprocessorMerger::ScopedPreprocessorMerger(MainController* mc) |
| 768 | { |
nothing calls this directly
no test coverage detected