2019-01-14 17:53:19 +00:00
|
|
|
package manager
|
|
|
|
|
|
|
|
import (
|
2025-03-07 19:14:14 +01:00
|
|
|
"fmt"
|
2019-01-28 17:50:05 +00:00
|
|
|
"path/filepath"
|
2019-01-14 17:53:19 +00:00
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2025-03-07 19:14:14 +01:00
|
|
|
// This is made slightly more complex due to needing to be case-insensitive.
|
2019-01-14 17:53:19 +00:00
|
|
|
func trimExeSuffix(s string) (string, error) {
|
2019-01-28 17:50:05 +00:00
|
|
|
ext := filepath.Ext(s)
|
2025-03-07 19:14:14 +01:00
|
|
|
if ext == "" || !strings.EqualFold(ext, ".exe") {
|
|
|
|
return "", fmt.Errorf("path %q lacks required file extension (.exe)", s)
|
2019-01-14 17:53:19 +00:00
|
|
|
}
|
2019-01-28 17:50:05 +00:00
|
|
|
return strings.TrimSuffix(s, ext), nil
|
2019-01-14 17:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func addExeSuffix(s string) string {
|
|
|
|
return s + ".exe"
|
|
|
|
}
|