forked from glycerine/sshego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exists.go
42 lines (38 loc) · 786 Bytes
/
exists.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package sshego
import (
"os"
)
// fileExists returns true iff the path name is a file (and not a directory or non-existant).
func fileExists(name string) bool {
fi, err := os.Stat(name)
if err != nil {
return false
}
if fi.IsDir() {
return false
}
return true
}
// FileExistsLen check if name is an actually file (directories don't count) and also
// returns the length of the file.
func fileExistsLen(name string) (bool, int64) {
fi, err := os.Stat(name)
if err != nil {
return false, 0
}
if fi.IsDir() {
return false, 0
}
return true, fi.Size()
}
// DirExists returns true if name represents a directory on disk.
func dirExists(name string) bool {
fi, err := os.Stat(name)
if err != nil {
return false
}
if fi.IsDir() {
return true
}
return false
}