(path string)
| 28 | } |
| 29 | |
| 30 | func translateCygwinPath(path string) (string, error) { |
| 31 | cmd, err := subprocess.ExecCommand("cygpath", "-w", path) |
| 32 | if err != nil { |
| 33 | // If cygpath doesn't exist, that's okay: just return the paths |
| 34 | // as we got it. |
| 35 | return path, nil |
| 36 | } |
| 37 | // cygpath uses ISO-8850-1 as the default encoding if the locale is not |
| 38 | // set, resulting in breakage, since we want a UTF-8 path. |
| 39 | env := make([]string, 0, len(cmd.Env)+1) |
| 40 | for _, val := range cmd.Env { |
| 41 | if !strings.HasPrefix(val, "LC_ALL=") { |
| 42 | env = append(env, val) |
| 43 | } |
| 44 | } |
| 45 | cmd.Env = append(env, "LC_ALL=C.UTF-8") |
| 46 | buf := &bytes.Buffer{} |
| 47 | cmd.Stderr = buf |
| 48 | out, err := cmd.Output() |
| 49 | output := strings.TrimSpace(string(out)) |
| 50 | if err != nil { |
| 51 | // If cygpath doesn't exist, that's okay: just return the paths |
| 52 | // as we got it. |
| 53 | if _, ok := err.(*exec.Error); ok { |
| 54 | return path, nil |
| 55 | } |
| 56 | return path, errors.New(tr.Tr.Get("failed to translate path from Cygwin to Windows: %s", buf.String())) |
| 57 | } |
| 58 | return output, nil |
| 59 | } |
| 60 | |
| 61 | func TranslateCygwinPath(path string) (string, error) { |
| 62 | if isCygwin() { |
no test coverage detected