6 "golang.org/x/net/context"
9 // ReaddirAll reads all the directory entries for the resource fid.
10 func ReaddirAll(session Session, fid Fid) ([]Dir, error) {
11 panic("not implemented")
14 // Readdir helps one to implement the server-side of Session.Read on
17 nextfn func() (Dir, error)
18 buf *Dir // one-item buffer
23 func NewReaddir(codec Codec, next func() (Dir, error)) *Readdir {
30 func NewFixedReaddir(codec Codec, dir []Dir) *Readdir {
31 dirs := make([]Dir, len(dir))
32 copy(dirs, dir) // make our own copy!
34 return NewReaddir(codec,
46 func (rd *Readdir) Read(ctx context.Context, p []byte, offset int64) (n int, err error) {
47 if rd.offset != offset {
48 return 0, ErrBadoffset
65 dp, err = rd.codec.Marshal(d)
70 if len(p)+len(dp) > cap(p) {
71 // will over fill buffer. save item and exit.
80 if err == io.EOF && len(p) > 0 {
81 // Don't let io.EOF escape if we've written to p. 9p doesn't handle
86 rd.offset += int64(len(p))