Documentation ¶
Overview ¶
The filesys package implements drill.Node for the io/fs package.
Index ¶
- type FS
- func (f *FS) Fragment() string
- func (f *FS) FragmentReader() (r io.ReadCloser, err error)
- func (f *FS) Handlers() Handlers
- func (f *FS) Len() int
- func (f *FS) OrderedChild(i int) drill.Node
- func (f *FS) OrderedChildren() []drill.Node
- func (f *FS) UnorderedChild(name string) drill.Node
- func (f *FS) UnorderedChildren() map[string]drill.Node
- type Handler
- type HandlerFunc
- type Handlers
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FS ¶
FS wraps an fs.FS to implement drill.Node.
Included in FS are a number of FileHandlers. Any produced child FS will inherit these handlers.
In order to descend into a file, the file must have an extension that matches one of these handlers (according Handlers.Match). If there is a match, the handler is called, returning the node returned by the handler.
func NewFS ¶
NewFS returns an FS that wraps fsys, and includes a number of handlers. Returns an error if a handler pattern is malformed.
func (*FS) Fragment ¶
Fragment returns the content of the file. Returns an empty string if the file does not exist, is a directory, or otherwise returns an error.
func (*FS) FragmentReader ¶
func (f *FS) FragmentReader() (r io.ReadCloser, err error)
FragmentReader opens and returns the file.
func (*FS) OrderedChild ¶
OrderedChild returns the file at index i from the results of fs.ReadDir.
func (*FS) OrderedChildren ¶
OrderedChildren returns each file in the directory.
func (*FS) UnorderedChild ¶
UnorderedChild returns the file matching name, or nil if it does not exist. Returns nil if the wrapped FS does not implement fs.SubFS.
type Handler ¶
type Handler struct { Pattern string Func HandlerFunc }
Handler maps a glob pattern to a HandlerFunc.
type HandlerFunc ¶
HandlerFunc produces a drill.Node from the given file, usually by calling fsys.Open(name), and interpreting the contents of the file.