Documentation
¶
Index ¶
- type Node
- type NodeSet
- func (p NodeSet) All() NodeSet
- func (p NodeSet) Collect() ([]*Node, error)
- func (p NodeSet) Dir() NodeSet
- func (p NodeSet) File() NodeSet
- func (p NodeSet) First() (*Node, error)
- func (p NodeSet) IsDir() (is bool, err error)
- func (p NodeSet) Match(pattern string) NodeSet
- func (p NodeSet) ModTime() (modTime time.Time, err error)
- func (p NodeSet) Mode() (mode fs.FileMode, err error)
- func (p NodeSet) Name() (name string, err error)
- func (p NodeSet) Ok() bool
- func (p NodeSet) OnError(onErr func(error) bool) NodeSet
- func (p NodeSet) One() NodeSet
- func (p NodeSet) Path() (name string, err error)
- func (p NodeSet) Single() NodeSet
- func (p NodeSet) Size() (size int64, err error)
- func (p NodeSet) XGo_Any(name string) NodeSet
- func (p NodeSet) XGo_Child() NodeSet
- func (p NodeSet) XGo_Enum() iter.Seq[NodeSet]
- func (p NodeSet) XGo_first() (ret *Node, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct {
// Path is the absolute path to the file or directory (relative to the root
// of the file system).
Path string
// contains filtered or unexported fields
}
Node represents a file or directory in the file system.
func (*Node) Name ¶
Name returns the name of the file (or subdirectory) described by the entry. This name is only the final element of the path (the base name), not the entire path. For example, Name would return "hello.go" not "home/gopher/hello.go".
func (*Node) Size ¶
Size returns the size of the file in bytes. If the file is a directory, the size is system-dependent and should not be used.
type NodeSet ¶
NodeSet represents a set of file system nodes, along with any error that occurred while retrieving them.
func (NodeSet) All ¶
All returns a NodeSet containing all nodes. It's a cache operation for performance optimization when you need to traverse the nodes multiple times.
func (NodeSet) Dir ¶
Dir returns a NodeSet containing all child nodes of the nodes in the NodeSet that are directories.
func (NodeSet) File ¶
File returns a NodeSet containing all child nodes of the nodes in the NodeSet that are files (not directories).
func (NodeSet) Match ¶
Match returns a NodeSet containing all child nodes of the nodes in the NodeSet that match the specified pattern. The pattern syntax is the same as in path.Match. For example, "file*.txt" matches "file1.txt" and "file2.txt", but not "myfile.txt".
func (NodeSet) OnError ¶
OnError calls onErr for any error in the NodeSet and returns a new NodeSet without the nodes that have errors. If onErr returns false, it stops processing and returns a NodeSet without the remaining nodes.
func (NodeSet) One ¶
One returns a NodeSet containing the first node. It's a performance optimization when you only need the first node (stop early).
func (NodeSet) Path ¶
Path returns the path of the first node in the NodeSet. The path is the absolute path to the file or directory (relative to the root of the file system). Note the path is not started with a slash. For example, if the root of the file system is "/home/gopher" and the node represents the file "/home/gopher/a/b.go", Path would return "a/b.go". For the root node, Path would return "" (not "/").
func (NodeSet) Single ¶
Single returns a NodeSet containing the single node. If there are zero or more than one nodes, it returns an error. ErrNotFound or ErrMultiEntities is returned accordingly.
func (NodeSet) XGo_Any ¶
XGo_Any returns a NodeSet containing all descendant nodes (including the nodes themselves) with the specified name. If name is "file", it returns all file nodes. If name is "dir", it returns all directory nodes. If name is "", it returns all nodes.
- .**.file
- .**.dir
- .**.*
func (NodeSet) XGo_Child ¶
XGo_Child returns a NodeSet containing all child nodes of the nodes in the NodeSet.