MCPcopy Create free account
hub / github.com/chigraph/chigraph / saveToDisk

Method saveToDisk

libchigraph/src/GraphModule.cpp:669–698  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

667}
668
669Result GraphModule::saveToDisk() const {
670 Result res;
671
672 // can't serialize without a workspace...
673 if (!context().hasWorkspace()) {
674 res.addEntry("EUKN", "Cannot serialize without a worksapce", {});
675 return res;
676 }
677
678 auto modulePath = sourceFilePath();
679
680 try {
681 // create directories that conatain the path
682 fs::create_directories(modulePath.parent_path());
683
684 } catch (std::exception& e) {
685 res.addEntry("EUKN", "Failed to create directoires in workspace",
686 {{"Module File", modulePath.string()}});
687 return res;
688 }
689
690 // serialize
691 nlohmann::json toFill = graphModuleToJson(*this);
692
693 // save
694 fs::ofstream ostr(modulePath);
695 ostr << toFill.dump(2);
696
697 return res;
698}
699
700GraphFunction* GraphModule::getOrCreateFunction(std::string name,
701 std::vector<NamedDataType> dataIns,

Callers

nothing calls this directly

Calls 4

graphModuleToJsonFunction · 0.85
hasWorkspaceMethod · 0.80
addEntryMethod · 0.80
dumpMethod · 0.45

Tested by

no test coverage detected