Inline readFile/writeFile; remove unused FileTree alias
- readFile was dead code (defined but never called) - writeFile was a 7-line helper called only once in clunk; inlined as direct s.rootTree.Open + e.Write - FileTree type alias now unused after both deletions
This commit is contained in:
parent
082ba1c511
commit
54403a1ce2
|
|
@ -19,8 +19,6 @@ import (
|
|||
)
|
||||
|
||||
type (
|
||||
FileTree = fs.FileTree
|
||||
|
||||
syntheticFileInfo = fs.SyntheticFileInfo
|
||||
)
|
||||
|
||||
|
|
@ -157,22 +155,6 @@ func (s *Server) checkPerm(uname, path string, mode uint8) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func readFile(s FileTree, name string) ([]byte, error) {
|
||||
e, err := s.Open(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return e.Read()
|
||||
}
|
||||
|
||||
func writeFile(s FileTree, name string, data []byte) error {
|
||||
e, err := s.Open(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return e.Write(data)
|
||||
}
|
||||
|
||||
const readTimeout = 10 * time.Second
|
||||
|
||||
func (s *Server) Serve(conn net.Conn) {
|
||||
|
|
@ -673,7 +655,11 @@ func (s *Server) clunk(cs *connState, fc *plan9.Fcall) *plan9.Fcall {
|
|||
cs.mu.Unlock()
|
||||
if writable {
|
||||
input := strings.TrimSpace(string(data))
|
||||
if err := writeFile(s.rootTree, path[1:], []byte(input)); err != nil {
|
||||
e, err := s.rootTree.Open(path[1:])
|
||||
if err != nil {
|
||||
return errFcall(fc, err.Error())
|
||||
}
|
||||
if err := e.Write([]byte(input)); err != nil {
|
||||
return errFcall(fc, err.Error())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue