| 214 | } |
| 215 | |
| 216 | func (t *Toolchain) CheckAndRepair(silent bool) error { |
| 217 | // Default folder name is the first folder name of archive name, |
| 218 | // but it can be specified by archive name. |
| 219 | folderName := strings.Split(t.Path, string(filepath.Separator))[0] |
| 220 | if t.Archive != "" { |
| 221 | folderName = fileio.Base(t.Archive) |
| 222 | } |
| 223 | |
| 224 | // Use archive name as download file name if specified. |
| 225 | archive := expr.If(t.Archive != "", t.Archive, filepath.Base(t.Url)) |
| 226 | |
| 227 | // Check and repair resource. |
| 228 | toolsDir := filepath.Join(t.ctx.Downloads(), "tools") |
| 229 | repair := fileio.NewRepair(t.Url, t.ctx.Downloads(), archive, folderName, toolsDir, t.SHA256) |
| 230 | if err := repair.CheckAndRepair(t.ctx); err != nil { |
| 231 | return err |
| 232 | } |
| 233 | |
| 234 | // Print download & extract info. |
| 235 | if !silent { |
| 236 | if t.rootDir == "" { |
| 237 | color.PrintPass("toolchain: %s", "local") |
| 238 | color.PrintHint("Location: %s\n", strings.ReplaceAll(t.Url, "file:///", "")) |
| 239 | } else { |
| 240 | color.PrintPass("toolchain: %s", t.displayName) |
| 241 | color.PrintHint("Location: %s\n", t.rootDir) |
| 242 | } |
| 243 | } |
| 244 | return nil |
| 245 | } |
| 246 | |
| 247 | // Detect detect local installed MSVC. |
| 248 | func (t *Toolchain) Detect(toolchainName string) error { |