MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / writeLuaMethod

Method writeLuaMethod

Source/Core/CtrlrPanel/CtrlrPanelFileOperations.cpp:633–658  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

631
632
633Result CtrlrPanel::writeLuaMethod(const File &parentDir, ValueTree *method)
634{
635 if (method == nullptr)
636 return Result::fail("Method name is missing");
637
638 const String methodName = method->getProperty(Ids::luaMethodName);
639 const String methodCode = method->getProperty(Ids::luaMethodCode);
640 if (methodName.isEmpty())
641 return Result::fail("Method name is empty");
642
643 // Create file
644 const File methodFile = parentDir.getNonexistentChildFile(methodName,".lua",false);
645 if (methodFile.replaceWithText(methodCode))
646 {
647 method->setProperty(Ids::luaMethodName, methodFile.getFileNameWithoutExtension(), nullptr);
648 method->setProperty(Ids::luaMethodSourcePath, methodFile.getRelativePathFrom(getPanelLuaDir()), nullptr);
649 method->setProperty(Ids::luaMethodSource, (int)CtrlrLuaMethod::codeInFile, nullptr);
650 method->removeProperty(Ids::luaMethodCode,nullptr);
651 return Result::ok();
652 }
653 else
654 {
655 AlertWindow::showMessageBox(AlertWindow::WarningIcon, "Could not save lua method", "Could not save lua method", "OK");
656 return (Result::fail("saveLuaMethod: could not save lua method."));
657 }
658}
659
660Result CtrlrPanel::writeLuaMethodGroup(const File &parentDir, ValueTree *methodGroup)
661{

Callers

nothing calls this directly

Calls 8

replaceWithTextMethod · 0.80
getRelativePathFromMethod · 0.80
getPropertyMethod · 0.45
isEmptyMethod · 0.45
setPropertyMethod · 0.45
removePropertyMethod · 0.45

Tested by

no test coverage detected