| 1 | package desktoplauncher |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "path/filepath" |
| 6 | "strings" |
| 7 | ) |
| 8 | |
| 9 | func repairInstallerShortcuts(paths []string, resolveRoot func() (string, error), repair func(string, []string) error) error { |
| 10 | if len(paths) == 0 { |
| 11 | return fmt.Errorf("--repair-shortcuts requires at least one absolute .lnk path") |
| 12 | } |
| 13 | for _, path := range paths { |
| 14 | if !filepath.IsAbs(path) || !strings.EqualFold(filepath.Ext(path), ".lnk") { |
| 15 | return fmt.Errorf("--repair-shortcuts requires absolute .lnk paths: %q", path) |
| 16 | } |
| 17 | } |
| 18 | root, err := resolveRoot() |
| 19 | if err != nil { |
| 20 | return err |
| 21 | } |
| 22 | return repair(root, paths) |
| 23 | } |
| 24 |