Hilbish/util/util_unix.go

25 lines
334 B
Go
Raw Permalink Normal View History

2024-07-19 13:48:01 +00:00
//go:build unix
package util
import (
"os"
)
func FindExecutable(path string, inPath, dirs bool) error {
f, err := os.Stat(path)
if err != nil {
return err
}
if dirs {
if m := f.Mode(); m & 0111 != 0 {
return nil
}
} else {
if m := f.Mode(); !m.IsDir() && m & 0111 != 0 {
return nil
}
}
2024-12-29 05:12:06 +00:00
return ErrNotExec
}