diff --git a/serialfile.go b/serialfile.go index 77871d3..176038c 100644 --- a/serialfile.go +++ b/serialfile.go @@ -3,6 +3,7 @@ package files import ( "errors" "fmt" + "io/fs" "os" "path/filepath" ) @@ -51,10 +52,18 @@ func NewSerialFileWithFilter(path string, filter *Filter, stat os.FileInfo) (Nod case mode.IsDir(): // for directories, stat all of the contents first, so we know what files to // open when Entries() is called - contents, err := os.ReadDir(path) + entries, err := os.ReadDir(path) if err != nil { return nil, err } + contents := make([]fs.FileInfo, 0, len(entries)) + for _, entry := range entries { + content, err := entry.Info() + if err != nil { + return nil, err + } + contents = append(contents, content) + } return &serialFile{path, contents, stat, filter}, nil case mode&os.ModeSymlink != 0: target, err := os.Readlink(path)