| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package common | 5 package common |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "io" | 8 "io" |
| 9 "os" | 9 "os" |
| 10 "runtime" | 10 "runtime" |
| 11 | 11 |
| 12 "github.com/luci/luci-go/common/system/terminal" | 12 "github.com/luci/luci-go/common/system/terminal" |
| 13 ) | 13 ) |
| 14 | 14 |
| 15 // IsDirectory returns true if path is a directory and is accessible. | |
| 16 func IsDirectory(path string) bool { | |
| 17 fileInfo, err := os.Stat(path) | |
| 18 return err == nil && fileInfo.IsDir() | |
| 19 } | |
| 20 | |
| 21 // IsWindows returns True when running on the best OS there is. | 15 // IsWindows returns True when running on the best OS there is. |
| 22 func IsWindows() bool { | 16 func IsWindows() bool { |
| 23 return runtime.GOOS == "windows" | 17 return runtime.GOOS == "windows" |
| 24 } | 18 } |
| 25 | 19 |
| 26 // IsTerminal returns true if the specified io.Writer is a terminal. | 20 // IsTerminal returns true if the specified io.Writer is a terminal. |
| 27 func IsTerminal(out io.Writer) bool { | 21 func IsTerminal(out io.Writer) bool { |
| 28 f, ok := out.(*os.File) | 22 f, ok := out.(*os.File) |
| 29 if !ok { | 23 if !ok { |
| 30 return false | 24 return false |
| 31 } | 25 } |
| 32 return terminal.IsTerminal(int(f.Fd())) | 26 return terminal.IsTerminal(int(f.Fd())) |
| 33 } | 27 } |
| OLD | NEW |