| 1 |
// Copyright (c) 2019, Daniel Martà <[email protected]> |
| 2 |
// See LICENSE for licensing information |
| 3 |
|
| 4 |
//go:build windows |
| 5 |
|
| 6 |
package interp_test |
| 7 |
|
| 8 |
import "golang.org/x/sys/windows" |
| 9 |
|
| 10 |
// shortPathName is used for testing against DOS short names. |
| 11 |
// |
| 12 |
// Only used for testing, so we assume that a short path always fits in |
| 13 |
// 2*len(path) in UTF-16. |
| 14 |
func shortPathName(path string) (string, error) { |
| 15 |
src, err := windows.UTF16FromString(path) |
| 16 |
if err != nil { |
| 17 |
return "", err |
| 18 |
} |
| 19 |
dst := make([]uint16, len(src)*2) |
| 20 |
if _, err := windows.GetShortPathName(&src[0], &dst[0], uint32(len(dst))); err != nil { |
| 21 |
return "", err |
| 22 |
} |
| 23 |
return windows.UTF16ToString(dst), nil |
| 24 |
} |