diffDirsAt creates a tree of files with the same names that differ within two dirs.
(pathA, pathB string, node *Node, excludeFile func(fname string) bool)
| 116 | // diffDirsAt creates a tree of files with the same names |
| 117 | // that differ within two dirs. |
| 118 | func (br *Browser) diffDirsAt(pathA, pathB string, node *Node, excludeFile func(fname string) bool) { |
| 119 | da := fsx.Dirs(pathA) |
| 120 | db := fsx.Dirs(pathB) |
| 121 | |
| 122 | node.SetFileA(pathA).SetFileB(pathB) |
| 123 | |
| 124 | for _, pa := range da { |
| 125 | if excludeFile != nil && excludeFile(pa) { |
| 126 | continue |
| 127 | } |
| 128 | for _, pb := range db { |
| 129 | if pa == pb { |
| 130 | nn := NewNode(node) |
| 131 | nn.SetText(pa) |
| 132 | br.diffDirsAt(filepath.Join(pathA, pa), filepath.Join(pathB, pb), nn, excludeFile) |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | fsa := fsx.Filenames(pathA) |
| 138 | fsb := fsx.Filenames(pathB) |
| 139 | |
| 140 | for _, fa := range fsa { |
| 141 | isDir := false |
| 142 | for _, pa := range da { |
| 143 | if fa == pa { |
| 144 | isDir = true |
| 145 | break |
| 146 | } |
| 147 | } |
| 148 | if isDir { |
| 149 | continue |
| 150 | } |
| 151 | if excludeFile != nil && excludeFile(fa) { |
| 152 | continue |
| 153 | } |
| 154 | for _, fb := range fsb { |
| 155 | if fa != fb { |
| 156 | continue |
| 157 | } |
| 158 | pfa := filepath.Join(pathA, fa) |
| 159 | pfb := filepath.Join(pathB, fb) |
| 160 | |
| 161 | ca, err := os.ReadFile(pfa) |
| 162 | if err != nil { |
| 163 | slog.Error(err.Error()) |
| 164 | continue |
| 165 | } |
| 166 | cb, err := os.ReadFile(pfb) |
| 167 | if err != nil { |
| 168 | slog.Error(err.Error()) |
| 169 | continue |
| 170 | } |
| 171 | sa := string(ca) |
| 172 | sb := string(cb) |
| 173 | if sa == sb { |
| 174 | continue |
| 175 | } |
no test coverage detected