commit 8896dd2f1cb1def0ef2327e9efc61a00e716a54a
parent b180b1b7d4cc339f31713cea5e2ffa4bc7457119
Author: Matsuda Kenji <info@mtkn.jp>
Date: Wed, 18 Oct 2023 09:48:29 +0900
delete old functions
Diffstat:
| M | file.go | | | 127 | ------------------------------------------------------------------------------- |
1 file changed, 0 insertions(+), 127 deletions(-)
diff --git a/file.go b/file.go
@@ -5,16 +5,10 @@ import (
"fmt"
"io"
"path"
-// "strings"
)
type File interface {
-// Parent() (File, error)
-// Child() ([]File, error) // Children
-
Stat() (*FileInfo, error)
-// Qid() Qid
-// Open(mode OpenMode) error
Close() error
io.Reader
}
@@ -81,46 +75,6 @@ func getChildren(fsys FS, dirpath string) ([]File, error) {
return children, nil
}
-/*
-// Walkfile1 walks file tree one step down from f to the child specified by name.
-// It returns the destination File.
-// name must not "..".
-func walkfile1(f File, name string) (File, error) {
- children, err := f.Child()
- if children == nil {
- return nil, fmt.Errorf("get children: %v", err)
- }
- for _, child := range children {
- if child == nil {
- continue
- }
- s, err := child.Stat()
- if err != nil {
- continue
- }
- if s.Name() == name {
- return child, nil
- }
- }
- return nil, fmt.Errorf("not found")
-}
-
-// Walkfile walks the file tree starting at f following pathname.
-// pathname must not contain "..".
-func walkfile(f File, pathname string) (File, error) {
- pathname = path.Clean(pathname)
- wnames := strings.Split(pathname, "/")
- cwd := f
- var err error
- for _, p := range wnames {
- cwd, err = walkfile1(cwd, p)
- if err != nil {
- return nil, err
- }
- }
- return cwd, nil
-}*/
-
type ClientFile struct {
name string
path string // must not contain trailing slash.
@@ -129,53 +83,6 @@ type ClientFile struct {
iounit uint32
client *Client
}
-/*
-func (cf *ClientFile) Parent() (File, error) {
- parentPath := path.Dir(cf.path)
- return cf.client.walkFile(parentPath)
-}
-
-func (cf *ClientFile) Child() ([]File, error) {
- if cf.fid == nil || (cf.fid.omode != OREAD && cf.fid.omode != ORDWR) {
- if err := cf.Open(OREAD); err != nil {
- return nil, fmt.Errorf("open: %v", err)
- }
- if cf.fid != nil {
- defer cf.Open(cf.fid.omode)
- }
- defer cf.Close()
- }
- if cf.qid.Type&QTDIR == 0 {
- return nil, fmt.Errorf("not a directory")
- }
- var data []byte
- buf := make([]byte, cf.iounit)
- for {
- n, err := cf.Read(buf)
- if err == io.EOF {
- if n > 0 {
- data = append(data, buf[:n]...)
- }
- break
- } else if err != nil {
- return nil, fmt.Errorf("read dir: %v", err)
- }
- data = append(data, buf[:n]...)
- }
-
- var files []File
- for len(data) > 0 {
- stat := newStat(data)
- files = append(files, &ClientFile{
- name: stat.Name,
- path: path.Join(cf.name, stat.Name),
- client: cf.client,
- })
- data = data[stat.size()+2:]
- }
- return files, nil
-}
-*/
func (cf *ClientFile) Stat() (*FileInfo, error) {
st, err := cf.client.Stat(context.TODO(), cf.fid.fid)
@@ -184,41 +91,7 @@ func (cf *ClientFile) Stat() (*FileInfo, error) {
}
return &FileInfo{*st}, nil
}
-/*
-func (cf *ClientFile) Qid() Qid {
- if cf.fid == nil {
- cf.Open(OREAD)
- defer cf.Close()
- }
- return cf.qid
-}
-func (cf *ClientFile) Open(mode OpenMode) error {
- if cf.fid == nil {
- fid, err := cf.client.fPool.add()
- if err != nil {
- return fmt.Errorf("add fid: %v", err)
- }
- var wname []string
- if cf.path != "." {
- wname = strings.Split(path.Clean(cf.path), "/")
- }
- _, err = cf.client.Walk(context.TODO(), cf.client.rootFid.fid, fid.fid, wname)
- if err != nil {
- return fmt.Errorf("walk: %v", err)
- }
- cf.fid = fid
- }
- qid, iounit, err := cf.client.Open(context.TODO(), cf.fid.fid, mode)
- if err != nil {
- return fmt.Errorf("open: %v", err)
- }
- cf.qid = qid
- cf.iounit = iounit
- cf.fid.omode = mode
- return nil
-}
-*/
// Don't use closed file.
func (cf *ClientFile) Close() error {