Set the execute bit on Windows executables (fixes #1762)

This commit is contained in:
Jakob Borg
2015-05-05 21:19:59 +02:00
parent e6866ee980
commit 5fc0808f28
2 changed files with 25 additions and 3 deletions

View File

@@ -192,3 +192,21 @@ func copyFileContents(src, dst string) (err error) {
err = out.Sync()
return
}
var execExts map[string]bool
func init() {
// PATHEXT contains a list of executable file extensions, on Windows
pathext := filepath.SplitList(os.Getenv("PATHEXT"))
// We want the extensions in execExts to be lower case
execExts = make(map[string]bool, len(pathext))
for _, ext := range pathext {
execExts[strings.ToLower(ext)] = true
}
}
// IsWindowsExecutable returns true if the given path has an extension that is
// in the list of executable extensions.
func IsWindowsExecutable(path string) bool {
return execExts[strings.ToLower(filepath.Ext(path))]
}