commit - 8404fb355041ce5292210491b039d5c28b568098
commit + dfdc90e8217fbe1023860c90daff5415d2bc0ab9
blob - 54e1d785e47221b2a1766be11f5ffa9db492362a
blob + 0709db0a3573b41575fa0ce46e96fb4f576160c5
--- client.go
+++ client.go
import (
"golang.org/x/net/context"
- "io"
-
"net"
)
return copy(p, rread.Data), nil
}
-// Readdir implements Plan9 wire protocol specifics for reading Dir entries.
-func (c *client) Readdir(ctx context.Context, fid Fid) ([]*Dir, error) {
-
- errChan := make(chan error)
- doneChan := make(chan []*Dir)
-
- reader, writer := io.Pipe()
- buf := make([]byte, 256)
- offset := int64(0)
-
- go func() {
- for {
- n, err := c.Read(ctx, fid, buf, offset)
- if err != nil {
- errChan <- err
- break
- }
- if n == 0 {
- break
- }
- writer.Write(buf[:n])
- }
- writer.Close()
- }()
-
- go func() {
- dirs := []*Dir{}
- dir := &Dir{}
- for {
- err := DecodeDir(NewCodec(), reader, dir)
- if err != nil && err != io.EOF {
- errChan <- err
- break
- }
- dirs = append(dirs, dir)
- if err != nil {
- doneChan <- dirs
- }
- }
- }()
-
- select {
- case err := <-errChan:
- return nil, err
- case dirs := <-doneChan:
- return dirs, nil
- }
-}
-
func (c *client) Write(ctx context.Context, fid Fid, p []byte, offset int64) (n int, err error) {
resp, err := c.transport.send(ctx, MessageTwrite{
Fid: fid,
blob - 3b37420d69f4a52eb888486100d1177f174bb7c5
blob + ff2fd20cbe5bddfe06b2157dc145d0fc537287d0
--- session.go
+++ session.go
Remove(ctx context.Context, fid Fid) error
Walk(ctx context.Context, fid Fid, newfid Fid, names ...string) ([]Qid, error)
Read(ctx context.Context, fid Fid, p []byte, offset int64) (n int, err error)
- Readdir(ctx context.Context, fid Fid) ([]*Dir, error)
Write(ctx context.Context, fid Fid, p []byte, offset int64) (n int, err error)
Open(ctx context.Context, fid Fid, mode Flag) (Qid, uint32, error)
Create(ctx context.Context, parent Fid, name string, perm uint32, mode Flag) (Qid, uint32, error)