golang 根据everything原理简单实现文件遍历
package main
import (
"context"
"fmt"
"github.com/gentlemanautomaton/volmgmt/usn"
"github.com/gentlemanautomaton/volmgmt/volume"
)
func FindFileWin(dir string) []string {
list := make([]string, 0)
vol, err := volume.New(dir + "\\")
if err != nil {
fmt.Println("xxxxxx", err)
return list
}
defer vol.Close()
mft := vol.MFT()
defer mft.Close()
iter, err := mft.Enumerate(nil, usn.Min, usn.Max)
if err != nil {
fmt.Println("xxasdasd", err)
return list
}
defer iter.Close()
cache := usn.NewCache()
ctx := context.Background()
err = cache.ReadFrom(ctx, iter)
if err != nil {
return list
}
records := cache.Records()
fmt.Println(len(records))
return list
}
func main() {
FindFileWin("C:\\")
}