func (f *fileManagerSG) Store(name string) (err error) { sg, ok := f.signalGraphMap[name] if !ok { err = fmt.Errorf("fileManagerSG.Rename error: graph %s not found\n", name) return } var filename string if len(sg.PathPrefix()) == 0 { filename = sg.Filename() } else { filename = fmt.Sprintf("%s/%s", sg.PathPrefix(), sg.Filename()) } err = sg.WriteFile(filename) if err != nil { return } hint := behaviour.CreateXmlGraphHint(sg) hintfilename := f.HintFilename(filename) var buf []byte buf, err = hint.Write() if err != nil { return } err = tool.WriteFile(hintfilename, buf) return }
func (m *XmlMapping) WriteFile(filepath string) error { data, err := m.Write() if err != nil { return err } buf := make([]byte, len(data)+len(xmlHeader)) for i := 0; i < len(xmlHeader); i++ { buf[i] = xmlHeader[i] } for i := 0; i < len(data); i++ { buf[i+len(xmlHeader)] = data[i] } return tool.WriteFile(filepath, buf) }
func (p *XmlPlatform) WriteFile(filepath string) (err error) { var data []byte data, err = p.Write() if err != nil { return } buf := make([]byte, len(data)+len(xmlHeader)) for i := 0; i < len(xmlHeader); i++ { buf[i] = xmlHeader[i] } for i := 0; i < len(data); i++ { buf[i+len(xmlHeader)] = data[i] } err = tool.WriteFile(filepath, buf) return }
func (f *fileManagerMap) Store(name string) (err error) { m, ok := f.mappingMap[name] if !ok { err = fmt.Errorf("fileManagerMap.Store error: mapping %s not found.\n", name) return } context := m.Graph().ItsType().Context() gMgr := context.SignalGraphMgr() err = gMgr.Store(m.Graph().Filename()) if err != nil { log.Printf("fileManagerMap.Store WARNING: could not save graph file %s\n", m.Graph().Filename()) } pMgr := context.PlatformMgr() err = pMgr.Store(m.Platform().Filename()) if err != nil { log.Printf("fileManagerMap.Store WARNING: could not save platform file %s\n", m.Platform().Filename()) } var filename string if len(m.PathPrefix()) == 0 { filename = m.Filename() } else { filename = fmt.Sprintf("%s/%s", m.PathPrefix(), m.Filename()) } err = m.WriteFile(filename) if err != nil { return } hint := mapping.CreateXmlMappingHint(m) hintfilename := f.HintFilename(filename) var buf []byte buf, err = hint.Write() if err != nil { return } err = tool.WriteFile(hintfilename, buf) return }