commit e7fff8777cb6a3b21483df8d762b561238925d03
parent b175e1b42adde278c3b6d86cfe69f3a09cac11fc
Author: Matsuda Kenji <info@mtkn.jp>
Date: Sun, 10 Sep 2023 16:45:54 +0900
move function
Diffstat:
| M | file.go | | | 20 | +++++++++++++++++++- |
| M | fs.go | | | 19 | ------------------- |
2 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/file.go b/file.go
@@ -1,10 +1,28 @@
package lib9p
type File interface {
- Parent() (File, error) // Parent Directory
Child() ([]File, error) // Children
Stat() (*FileInfo, error)
Close() error
Read(b []byte) (int, error)
}
+
+// Walkfile walks file tree starting at f, following path specified by name.
+// It returns the destination File and nil, or nil with non-nil error.
+func walkfile(f File, name string) (File, error) {
+ children, err := f.Child()
+ if err != nil {
+ return nil, fmt.Errorf("get children: %v", err)
+ }
+ for _, child := range children {
+ s, err := child.Stat()
+ if err != nil {
+ return nil, fmt.Errorf("stat: %v", err)
+ }
+ if s.Name() == name {
+ return child, nil
+ }
+ }
+ return nil, fmt.Errorf("not found")
+}
diff --git a/fs.go b/fs.go
@@ -9,25 +9,6 @@ type FS interface {
Open(string) (File, error)
}
-// Walkfile walks file tree starting at f, following path specified by name.
-// It returns the destination file and nil, or nil with non-nil error.
-func walkfile(f File, name string) (File, error) {
- children, err := f.Child()
- if err != nil {
- return nil, fmt.Errorf("get children: %v", err)
- }
- for _, child := range children {
- s, err := child.Stat()
- if err != nil {
- return nil, fmt.Errorf("stat: %v", err)
- }
- if s.Name() == name {
- return child, nil
- }
- }
- return nil, fmt.Errorf("not found")
-}
-
func FSModeToQidType(fm fs.FileMode) QidType {
var qt QidType
if fm&fs.ModeDir != 0 {