Blob
1 package fs3 import (4 "io"5 "io/fs"6 )8 type dirInfo struct {9 entries []fs.DirEntry10 entryp int11 }13 func (d *dirInfo) ReadDir(n int) ([]fs.DirEntry, error) {14 entries := d.entries[d.entryp:]15 if n < 0 {16 d.entryp = len(d.entries) // advance to the end17 if len(entries) == 0 {18 return nil, nil19 }20 return entries, nil21 }23 var err error24 if n >= len(entries) {25 err = io.EOF26 } else if d.entryp >= len(d.entries) {27 err = io.EOF28 } else {29 entries = entries[:n-1]30 }31 d.entryp += n32 return entries, err33 }