parent
286bf75aa9
commit
ac4bdccf8d
28
nav.go
28
nav.go
@ -554,6 +554,34 @@ func (nav *nav) previewLoop(ui *ui) {
|
||||
}
|
||||
}
|
||||
|
||||
func isDirty(f os.FileInfo, path string, dirtyfiles []string) bool {
|
||||
dirty := false
|
||||
for _, pattern := range dirtyfiles {
|
||||
matched := matchPattern(strings.TrimPrefix(pattern, "!"), f.Name(), path)
|
||||
if strings.HasPrefix(pattern, "!") && matched {
|
||||
dirty = false
|
||||
} else if matched {
|
||||
dirty = true
|
||||
}
|
||||
}
|
||||
return dirty
|
||||
}
|
||||
|
||||
func matchPattern(pattern, name, path string) bool {
|
||||
s := name
|
||||
|
||||
pattern = replaceTilde(pattern)
|
||||
|
||||
if filepath.IsAbs(pattern) {
|
||||
s = filepath.Join(path, name)
|
||||
}
|
||||
|
||||
// pattern errors are checked when 'hiddenfiles' option is set
|
||||
matched, _ := filepath.Match(pattern, s)
|
||||
|
||||
return matched
|
||||
}
|
||||
|
||||
func (nav *nav) preview(path string, win *win) {
|
||||
reg := ®{loadTime: time.Now(), path: path}
|
||||
defer func() { nav.regChan <- reg }()
|
||||
|
28
os.go
28
os.go
@ -136,19 +136,6 @@ func isHidden(f os.FileInfo, path string, hiddenfiles []string) bool {
|
||||
return hidden
|
||||
}
|
||||
|
||||
func isDirty(f os.FileInfo, path string, dirtyfiles []string) bool {
|
||||
dirty := false
|
||||
for _, pattern := range dirtyfiles {
|
||||
matched := matchPattern(strings.TrimPrefix(pattern, "!"), f.Name(), path)
|
||||
if strings.HasPrefix(pattern, "!") && matched {
|
||||
dirty = false
|
||||
} else if matched {
|
||||
dirty = true
|
||||
}
|
||||
}
|
||||
return dirty
|
||||
}
|
||||
|
||||
func userName(f os.FileInfo) string {
|
||||
if stat, ok := f.Sys().(*syscall.Stat_t); ok {
|
||||
if u, err := user.LookupId(fmt.Sprint(stat.Uid)); err == nil {
|
||||
@ -174,21 +161,6 @@ func linkCount(f os.FileInfo) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func matchPattern(pattern, name, path string) bool {
|
||||
s := name
|
||||
|
||||
pattern = replaceTilde(pattern)
|
||||
|
||||
if filepath.IsAbs(pattern) {
|
||||
s = filepath.Join(path, name)
|
||||
}
|
||||
|
||||
// pattern errors are checked when 'hiddenfiles' option is set
|
||||
matched, _ := filepath.Match(pattern, s)
|
||||
|
||||
return matched
|
||||
}
|
||||
|
||||
func errCrossDevice(err error) bool {
|
||||
return err.(*os.LinkError).Err.(syscall.Errno) == syscall.EXDEV
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user