From daaa0fa467c75fadd3227a6e909953bdc77d2e0a Mon Sep 17 00:00:00 2001
From: Mandar Limaye <mandar.limaye@verizon.com>
Date: Tue, 9 Aug 2016 12:07:21 -0500
Subject: [PATCH 1/3] Add conditional build files for unix.Access. This will
 allow library to be built on windows.

---
 access_unix.go |  9 +++++++++
 access_win.go  | 15 +++++++++++++++
 server.go      |  3 +--
 unix.go        | 11 +++++++++++
 4 files changed, 36 insertions(+), 2 deletions(-)
 create mode 100644 access_unix.go
 create mode 100644 access_win.go
 create mode 100644 unix.go

diff --git a/access_unix.go b/access_unix.go
new file mode 100644
index 0000000..a1f8894
--- /dev/null
+++ b/access_unix.go
@@ -0,0 +1,9 @@
+// +build darwin freebsd linux netbsd openbsd
+
+package adb
+
+import "golang.org/x/sys/unix"
+
+func access(path string) error {
+	return unix.Access(path, unix.X_OK)
+}
diff --git a/access_win.go b/access_win.go
new file mode 100644
index 0000000..2d84abe
--- /dev/null
+++ b/access_win.go
@@ -0,0 +1,15 @@
+// +build windows
+
+package adb
+
+import (
+	"errors"
+	"strings"
+)
+
+func access(path string) error {
+	if strings.Contains(path, ".exe") {
+		return nil
+	}
+	return errors.New("not an executable")
+}
diff --git a/server.go b/server.go
index f5a91e7..e826537 100644
--- a/server.go
+++ b/server.go
@@ -9,7 +9,6 @@ import (
 
 	"github.com/zach-klippenstein/goadb/internal/errors"
 	"github.com/zach-klippenstein/goadb/wire"
-	"golang.org/x/sys/unix"
 )
 
 const (
@@ -137,7 +136,7 @@ var localFilesystem = &filesystem{
 		if !info.Mode().IsRegular() {
 			return stderrors.New("not a regular file")
 		}
-		return unix.Access(path, unix.X_OK)
+		return Access(path)
 	},
 	CmdCombinedOutput: func(name string, arg ...string) ([]byte, error) {
 		return exec.Command(name, arg...).CombinedOutput()
diff --git a/unix.go b/unix.go
new file mode 100644
index 0000000..c87b6a8
--- /dev/null
+++ b/unix.go
@@ -0,0 +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
+*/
+func Access(path string) error {
+	return access(path)
+}

From 5d71bb68b46df9c18ef22decbe17911cc1a4644d Mon Sep 17 00:00:00 2001
From: Mandar Limaye <mandar.limaye@verizon.com>
Date: Fri, 26 Aug 2016 20:17:20 -0500
Subject: [PATCH 2/3] refactor code

---
 access_unix.go |  2 +-
 access_win.go  |  5 +++--
 server.go      |  2 +-
 unix.go        | 12 ++++++------
 4 files changed, 11 insertions(+), 10 deletions(-)

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)
 }

From cd529c014ac6f25f399dcc678006c14aa6fb9a36 Mon Sep 17 00:00:00 2001
From: Mandar Limaye <mandar.limaye@verizon.com>
Date: Fri, 26 Aug 2016 20:25:25 -0500
Subject: [PATCH 3/3] renamed files for platform specific isExecutable()

---
 unix.go => executable.go             | 0
 access_unix.go => executable_unix.go | 0
 access_win.go => executable_win.go   | 0
 3 files changed, 0 insertions(+), 0 deletions(-)
 rename unix.go => executable.go (100%)
 rename access_unix.go => executable_unix.go (100%)
 rename access_win.go => executable_win.go (100%)

diff --git a/unix.go b/executable.go
similarity index 100%
rename from unix.go
rename to executable.go
diff --git a/access_unix.go b/executable_unix.go
similarity index 100%
rename from access_unix.go
rename to executable_unix.go
diff --git a/access_win.go b/executable_win.go
similarity index 100%
rename from access_win.go
rename to executable_win.go