You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Make sure name exists.
stat, err := os.Stat(name)
if err != nil {
return nil, err
}
fileList[name] = stat
// If it's not a directory, just return.
if !stat.IsDir() {
return fileList, nil
}
// It's a directory.
fInfoList, err := ioutil.ReadDir(name)
if err != nil {
return nil, err
}
// Add all of the files in the directory to the file list as long
// as they aren't on the ignored list or are hidden files if ignoreHidden
// is set to true.
outer:
for _, fInfo := range fInfoList {
path := filepath.Join(name, fInfo.Name())
_, ignored := w.ignored[path]
isHidden, err := isHiddenFile(path)
if err != nil {
return nil, err
}
if ignored || (w.ignoreHidden && isHidden) {
continue
}
for _, f := range w.ffh {
err := f(fInfo, path)
if err == ErrSkip {
continue outer
}
if err != nil {
return nil, err
}
}
// asaf: handle symlink files
for fInfo.Mode()&os.ModeSymlink != 0 {
link, err1 := os.Readlink(path)
if err1 != nil {
continue outer
}
fInfo, err1 = os.Stat(link)
if err1 != nil {
continue outer
}
}
// asaf: end update
fileList[path] = fInfo
}
return fileList, nil
}
The text was updated successfully, but these errors were encountered:
I update the code to support symlink files.
If the folder includes symlink it will follow and monitor the pointed file.
func (w *Watcher) list(name string) (map[string]os.FileInfo, error) {
fileList := make(map[string]os.FileInfo)
outer:
for _, fInfo := range fInfoList {
path := filepath.Join(name, fInfo.Name())
_, ignored := w.ignored[path]
}
The text was updated successfully, but these errors were encountered: