(fs []*files.File)
| 25 | } |
| 26 | |
| 27 | func NewRootLibrary(fs []*files.File) *Library { |
| 28 | rootLibrary := &Library{} |
| 29 | |
| 30 | for _, file := range fs { |
| 31 | dirPieces, _ := files.SplitPath(file.RelativePath()) |
| 32 | |
| 33 | var currLibrary *Library = rootLibrary |
| 34 | for _, piece := range dirPieces { |
| 35 | lib, found := currLibrary.findLibrary(piece) |
| 36 | if !found { |
| 37 | currLibrary = currLibrary.CreateLibrary(piece) |
| 38 | } else { |
| 39 | currLibrary = lib |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | currLibrary.files = append(currLibrary.files, file) |
| 44 | } |
| 45 | |
| 46 | return rootLibrary |
| 47 | } |
| 48 | |
| 49 | func (l *Library) findLibrary(name string) (*Library, bool) { |
| 50 | for _, lib := range l.children { |
no test coverage detected
searching dependent graphs…