dynamic

package
v0.0.0-...-6c8fb3a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2020 License: BSD-3-Clause, MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicDirHandler

type BasicDirHandler struct {
	S      *Server
	Filter func(name string) bool
}

A basic directory handler interprets the file

entries to show its children. The handler
does not support the creation of any children files.

func (*BasicDirHandler) Clunk

func (b *BasicDirHandler) Clunk(name string, fid protocol.FID) error

func (*BasicDirHandler) CreateChild

func (b *BasicDirHandler) CreateChild(name string, child string) (int, error)

func (*BasicDirHandler) Open

func (b *BasicDirHandler) Open(name string, fid protocol.FID, mode protocol.Mode) error

func (*BasicDirHandler) Read

func (b *BasicDirHandler) Read(name string, fid protocol.FID, offset int64, count int64) ([]byte, error)

func (*BasicDirHandler) Remove

func (b *BasicDirHandler) Remove(name string) error

func (*BasicDirHandler) Stat

func (b *BasicDirHandler) Stat(name string) (protocol.Dir, error)

func (*BasicDirHandler) WalkChild

func (b *BasicDirHandler) WalkChild(name string, child string) (int, error)

func (*BasicDirHandler) Write

func (b *BasicDirHandler) Write(name string, fid protocol.FID, offset int64, buf []byte) (int64, error)

func (*BasicDirHandler) Wstat

func (b *BasicDirHandler) Wstat(name string, dir protocol.Dir) error

type FileEntry

type FileEntry struct {
	Name string

	Handler FileHandler
	// contains filtered or unexported fields
}

A file entry is a location in the filesystem tree with a handler

that handles the file operations for it. The server keeps track
of the QID and FID's of the entries.

func NewFileEntry

func NewFileEntry(name string, handler FileHandler) FileEntry

type FileHandler

type FileHandler interface {
	WalkChild(name string, child string) (int, error)
	Open(name string, fid protocol.FID, mode protocol.Mode) error
	CreateChild(name string, child string) (int, error)
	Stat(name string) (protocol.Dir, error)
	Wstat(name string, dir protocol.Dir) error
	Remove(name string) error
	Read(name string, fid protocol.FID, offset int64, count int64) ([]byte, error)
	Write(name string, fid protocol.FID, offset int64, buf []byte) (int64, error)
	Clunk(name string, fid protocol.FID) error
}

A file handler defines the behaviour of one or more file entries

type Server

type Server struct {
	// contains filtered or unexported fields
}

A server

func NewServer

func NewServer(files []FileEntry, opts ...protocol.ServerOpt) (*protocol.Server, *Server, error)

func (*Server) AddFileEntry

func (s *Server) AddFileEntry(name string, handler FileHandler) int

func (*Server) HasChildren

func (s *Server) HasChildren(name string) bool

func (*Server) MatchFile

func (s *Server) MatchFile(matcher func(f *FileEntry) bool) int

func (*Server) MatchFiles

func (s *Server) MatchFiles(matcher func(f *FileEntry) bool) []int

func (*Server) Rattach

func (s *Server) Rattach(fid protocol.FID, afid protocol.FID, uname string, aname string) (protocol.QID, error)

func (*Server) Rclunk

func (s *Server) Rclunk(fid protocol.FID) error

func (*Server) Rcreate

func (s *Server) Rcreate(fid protocol.FID, name string, perm protocol.Perm, mode protocol.Mode) (protocol.QID, protocol.MaxSize, error)

func (*Server) Rflush

func (s *Server) Rflush(o protocol.Tag) error

func (*Server) Ropen

func (s *Server) Ropen(fid protocol.FID, mode protocol.Mode) (protocol.QID, protocol.MaxSize, error)

func (*Server) Rread

func (s *Server) Rread(fid protocol.FID, o protocol.Offset, c protocol.Count) ([]byte, error)

func (*Server) Rremove

func (s *Server) Rremove(fid protocol.FID) error

func (*Server) Rstat

func (s *Server) Rstat(fid protocol.FID) ([]byte, error)

func (*Server) Rversion

func (s *Server) Rversion(msize protocol.MaxSize, version string) (protocol.MaxSize, string, error)

func (*Server) Rwalk

func (s *Server) Rwalk(fid protocol.FID, newfid protocol.FID, paths []string) ([]protocol.QID, error)

func (*Server) Rwrite

func (s *Server) Rwrite(fid protocol.FID, o protocol.Offset, b []byte) (protocol.Count, error)

func (*Server) Rwstat

func (s *Server) Rwstat(fid protocol.FID, b []byte) error

type ServerOpt

type ServerOpt func(*protocol.Server) error

type StaticFileHandler

type StaticFileHandler struct {
	Content []byte
}

Static file handler has a static contents that

is initiated at startup and cannot be modified.
This is useful for README files and other helpful
documentation for your filesystem.

func (*StaticFileHandler) Clunk

func (f *StaticFileHandler) Clunk(name string, fid protocol.FID) error

func (*StaticFileHandler) CreateChild

func (f *StaticFileHandler) CreateChild(name string, child string) (int, error)

func (*StaticFileHandler) Open

func (f *StaticFileHandler) Open(name string, fid protocol.FID, mode protocol.Mode) error

func (*StaticFileHandler) Read

func (f *StaticFileHandler) Read(name string, fid protocol.FID, offset int64, count int64) ([]byte, error)

func (*StaticFileHandler) Remove

func (f *StaticFileHandler) Remove(name string) error

func (*StaticFileHandler) Stat

func (f *StaticFileHandler) Stat(name string) (protocol.Dir, error)

func (*StaticFileHandler) WalkChild

func (f *StaticFileHandler) WalkChild(name string, child string) (int, error)

func (*StaticFileHandler) Write

func (f *StaticFileHandler) Write(name string, fid protocol.FID, offset int64, buf []byte) (int64, error)

func (*StaticFileHandler) Wstat

func (f *StaticFileHandler) Wstat(name string, qid protocol.Dir) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL