Documentation
¶
Index ¶
- type FSNode
- type MemoryFS
- func (fs *MemoryFS) Add(path string, item MemoryItem) error
- func (fs *MemoryFS) BuildFromMemories(memories []MemoryItem) *MemoryFS
- func (fs *MemoryFS) Get(path string) *FSNode
- func (fs *MemoryFS) List(path string) []*FSNode
- func (fs *MemoryFS) Remove(path string) error
- func (fs *MemoryFS) Search(query string) []*FSNode
- func (fs *MemoryFS) Tree(path string, depth int) string
- type MemoryItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FSNode ¶
type FSNode struct {
Name string
Type string // "dir" or "file"
Children []*FSNode
MemoryID string
Content string
CreatedAt time.Time
}
FSNode represents a node in the memory filesystem tree.
type MemoryFS ¶
type MemoryFS struct {
Root *FSNode
// contains filtered or unexported fields
}
MemoryFS provides a filesystem-style interface for browsing memories.
func NewMemoryFS ¶
func NewMemoryFS() *MemoryFS
NewMemoryFS creates a new MemoryFS with an empty root directory.
func (*MemoryFS) Add ¶
func (fs *MemoryFS) Add(path string, item MemoryItem) error
Add inserts a memory item at the specified path. Intermediate directories are created as needed. The final path component becomes the file name.
func (*MemoryFS) BuildFromMemories ¶
func (fs *MemoryFS) BuildFromMemories(memories []MemoryItem) *MemoryFS
BuildFromMemories organizes flat memory items into a tree structure grouped by Category (first level directory) and Type (second level directory). Each memory becomes a file node named by its ID.
func (*MemoryFS) List ¶
List returns the children of the directory at the given path, similar to `ls`. Returns nil if the path does not exist or is not a directory.