Documentation
¶
Overview ¶
Package structfs defines a data structure for a file system, similar to the fs package but based on structs instead of interfaces.
The entire tree structure and directory entry metadata is stored in memory. File content is represented with Blob, and may come from various sources.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidName ¶
ValidName reports whether the given name is a valid node name.
The name must be UTF-8-encoded, must not be empty, "." or "..", and must not contain "/". These are the same rules as for a path element in fs.ValidPath.
Types ¶
type Blob ¶
type Blob interface { Open() (io.ReadCloser, error) Size() int64 }
Blob is a binary large object, a read-only sequence of bytes of a known size.
type Node ¶
type Node struct { // Name of this node, which must be valid according to [ValidName]. Name string // Mode contains the file type and permissions. Mode fs.FileMode // ModTime is the modification time. ModTime time.Time // Content is the file content, must be set for regular files. Content Blob // Children of a directory, must be empty if this is not a directory. Children Tree // Sys contains any system-specific directory entry fields. // // It should be accessed using interface type assertions, to allow combining // information for multiple target systems with struct embedding. Sys any }
Node is a node in a file system tree, which is either a file or directory.
type Option ¶
type Option func(*Node)
type Tree ¶
type Tree []*Node
Tree represents a file system tree.
func (*Tree) Place ¶
Place creates directories if necessary and places the node in the directory at the path.
The special path "." indicates the root.
func (*Tree) PlaceDir ¶
PlaceDir creates parent directories if necessary and places a directory with the given children at the path. It fails if path already exists.