summaryrefslogtreecommitdiff
path: root/vendor/github.com/moby/term/windows/console.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-09-17 15:18:17 -0400
committerGitHub <noreply@github.com>2020-09-17 15:18:17 -0400
commit175d7b19dd15381d13082f896d7ce1594d7bdefa (patch)
tree7d78fa45249684da3a34dffe5e9475dca3fa529b /vendor/github.com/moby/term/windows/console.go
parentdc23ef1cbf57458b6c47f3585e3433aaddc58184 (diff)
parent661786808c8a5249e05672af1f4d9cfaef39b38e (diff)
downloadpodman-175d7b19dd15381d13082f896d7ce1594d7bdefa.tar.gz
podman-175d7b19dd15381d13082f896d7ce1594d7bdefa.tar.bz2
podman-175d7b19dd15381d13082f896d7ce1594d7bdefa.zip
Merge pull request #7677 from AkihiroSuda/update-moby-20200918
update github.com/docker/docker and relevant deps
Diffstat (limited to 'vendor/github.com/moby/term/windows/console.go')
-rw-r--r--vendor/github.com/moby/term/windows/console.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/vendor/github.com/moby/term/windows/console.go b/vendor/github.com/moby/term/windows/console.go
new file mode 100644
index 000000000..01fdc0f2a
--- /dev/null
+++ b/vendor/github.com/moby/term/windows/console.go
@@ -0,0 +1,39 @@
+// +build windows
+
+package windowsconsole
+
+import (
+ "os"
+
+ "golang.org/x/sys/windows"
+)
+
+// GetHandleInfo returns file descriptor and bool indicating whether the file is a console.
+func GetHandleInfo(in interface{}) (uintptr, bool) {
+ switch t := in.(type) {
+ case *ansiReader:
+ return t.Fd(), true
+ case *ansiWriter:
+ return t.Fd(), true
+ }
+
+ var inFd uintptr
+ var isTerminal bool
+
+ if file, ok := in.(*os.File); ok {
+ inFd = file.Fd()
+ isTerminal = isConsole(inFd)
+ }
+ return inFd, isTerminal
+}
+
+// IsConsole returns true if the given file descriptor is a Windows Console.
+// The code assumes that GetConsoleMode will return an error for file descriptors that are not a console.
+// Deprecated: use golang.org/x/sys/windows.GetConsoleMode() or golang.org/x/crypto/ssh/terminal.IsTerminal()
+var IsConsole = isConsole
+
+func isConsole(fd uintptr) bool {
+ var mode uint32
+ err := windows.GetConsoleMode(windows.Handle(fd), &mode)
+ return err == nil
+}