MCPcopy Create free account
hub / github.com/HashLoad/boss / updateLibraryPathProject

Function updateLibraryPathProject

utils/librarypath/dproj_itil.go:91–128  ·  view source on GitHub ↗
(dprojName string)

Source from the content-addressed store, hash-verified

89}
90
91func updateLibraryPathProject(dprojName string) {
92 doc := etree.NewDocument()
93 info, err := os.Stat(dprojName)
94 if os.IsNotExist(err) || info.IsDir() {
95 msg.Err(".dproj not found.")
96 return
97 }
98 e := doc.ReadFromFile(dprojName)
99 if e != nil {
100 msg.Err("Error on read dproj: %s", e)
101 return
102 }
103 root := doc.Root()
104
105 childrens := root.FindElements(consts.XmlTagNameProperty)
106 for _, children := range childrens {
107 attribute := children.SelectAttr(consts.XmlTagNamePropertyAttribute)
108 if attribute != nil && attribute.Value == consts.XmlTagNamePropertyAttributeValue {
109 child := children.SelectElement(consts.XmlTagNameLibraryPath)
110 if child == nil {
111 child = createTagLibraryPath(children)
112 }
113 rootPath := filepath.Join(env.GetCurrentDir(), path.Dir(dprojName))
114 if _, err := os.Stat(rootPath); os.IsNotExist(err) {
115 rootPath = env.GetCurrentDir()
116 }
117 processCurrentPath(child, rootPath)
118 }
119 }
120
121 doc.WriteSettings.CanonicalAttrVal = true
122 doc.WriteSettings.CanonicalEndTags = false
123 doc.WriteSettings.CanonicalText = true
124
125 if err := doc.WriteToFile(dprojName); err != nil {
126 panic(err)
127 }
128}
129
130func createTagLibraryPath(node *etree.Element) *etree.Element {
131 child := node.CreateElement(consts.XmlTagNameLibraryPath)

Callers 1

updateDprojLibraryPathFunction · 0.85

Calls 4

ErrFunction · 0.92
GetCurrentDirFunction · 0.92
createTagLibraryPathFunction · 0.85
processCurrentPathFunction · 0.85

Tested by

no test coverage detected