diff --git a/access_unix.go b/access_unix.go index a1f8894..d1b947c 100644 --- a/access_unix.go +++ b/access_unix.go @@ -4,6 +4,6 @@ package adb import "golang.org/x/sys/unix" -func access(path string) error { +func isExecutableOnPlatform(path string) error { return unix.Access(path, unix.X_OK) } diff --git a/access_win.go b/access_win.go index 2d84abe..4652eca 100644 --- a/access_win.go +++ b/access_win.go @@ -7,8 +7,9 @@ import ( "strings" ) -func access(path string) error { - if strings.Contains(path, ".exe") { +func isExecutableOnPlatform(path string) error { + if strings.HasSuffix(path, ".exe") || strings.HasSuffix(path, ".cmd") || + strings.HasSuffix(path, ".bat") { return nil } return errors.New("not an executable") diff --git a/server.go b/server.go index e826537..6b6d135 100644 --- a/server.go +++ b/server.go @@ -136,7 +136,7 @@ var localFilesystem = &filesystem{ if !info.Mode().IsRegular() { return stderrors.New("not a regular file") } - return Access(path) + return isExecutable(path) }, CmdCombinedOutput: func(name string, arg ...string) ([]byte, error) { return exec.Command(name, arg...).CombinedOutput() diff --git a/unix.go b/unix.go index c87b6a8..1794e94 100644 --- a/unix.go +++ b/unix.go @@ -1,11 +1,11 @@ package adb /* -Exported Access function calls private access function. -Implementation for private access function is provided in -access_win.go for windows and -access_unix.go for unix +isExecutable function calls the isExecutableOnPlatform function. +Implementation the isExecutableOnPlatform function is provided in +execuatble_win.go for windows and +executable_unix.go for unix. */ -func Access(path string) error { - return access(path) +func isExecutable(path string) error { + return isExecutableOnPlatform(path) }