-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutil.go
More file actions
48 lines (35 loc) · 736 Bytes
/
Copy pathutil.go
File metadata and controls
48 lines (35 loc) · 736 Bytes
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
43
44
45
46
47
48
package fwatch
import (
"os"
"path/filepath"
"github.com/vogo/fsnotify"
)
func IsDir(name string) bool {
stat, err := os.Stat(name)
return err == nil && stat != nil && stat.IsDir()
}
func unlink(path string, info os.FileInfo) (unlinkPath string, dir bool, fileErr error) {
if info.IsDir() {
return path, true, nil
}
var err error
for info.Mode()&os.ModeSymlink != 0 {
path, err = filepath.EvalSymlinks(path)
if err != nil {
return "", false, err
}
info, err = os.Lstat(path)
if err != nil {
return "", false, err
}
}
return path, info.IsDir(), nil
}
func opMatch(op fsnotify.Op, target ...fsnotify.Op) bool {
for _, t := range target {
if op&t != t {
return false
}
}
return true
}