(dprojName string)
| 89 | } |
| 90 | |
| 91 | func 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 | |
| 130 | func createTagLibraryPath(node *etree.Element) *etree.Element { |
| 131 | child := node.CreateElement(consts.XmlTagNameLibraryPath) |
no test coverage detected