Documentation
¶
Index ¶
- Constants
- type ChangeType
- type FileChange
- type FileNode
- func (n *FileNode) AddChild(child *FileNode)
- func (n *FileNode) GetChild(name string) *FileNode
- func (n *FileNode) GetChildren() map[string]*FileNode
- func (n *FileNode) HasChild(name string) bool
- func (n *FileNode) RemoveChild(name string)
- func (n *FileNode) SetMetadata(info os.FileInfo, stat *syscall.Stat_t)
- type FileTree
- type SnapshotConfig
- type SnapshotManager
- func (sm *SnapshotManager) Cleanup()
- func (sm *SnapshotManager) ClearCurrentSnapshot()
- func (sm *SnapshotManager) CreateSnapshot(rootPath string) (*FileTree, error)
- func (sm *SnapshotManager) GetCurrentSnapshot() *FileTree
- func (sm *SnapshotManager) GetPreviousSnapshot() *FileTree
- func (sm *SnapshotManager) GetSnapshotStats() (currentNodes, previousNodes int)
- func (sm *SnapshotManager) HasPreviousSnapshot() bool
- type TreeComparator
Constants ¶
const (
// MaxRecursionDepth limits the maximum depth of directory recursion to prevent stack overflow
MaxRecursionDepth = 50
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChangeType ¶
type ChangeType string
ChangeType represents the type of change detected
const ( ChangeTypeCreate ChangeType = "create" ChangeTypeModify ChangeType = "modify" ChangeTypeDelete ChangeType = "delete" ChangeTypeMove ChangeType = "move" ChangeTypeChmod ChangeType = "chmod" ChangeTypeRename ChangeType = "rename" )
type FileChange ¶
type FileChange struct {
Type ChangeType
Path string
OldNode *FileNode // nil for create
NewNode *FileNode // nil for delete
Timestamp time.Time
}
FileChange represents a detected change in the file system
type FileNode ¶
type FileNode struct {
Name string // File/directory name
Path string // Full path from root
IsDir bool // Whether this is a directory
Size int64 // File size in bytes
Inode uint64 // File inode number
Device uint64 // Device number
Mode uint32 // File permissions and type
Uid uint32 // Owner user ID
Gid uint32 // Owner group ID
Mtime time.Time // Last modification time
Ctime time.Time // Last status change time
Children map[string]*FileNode // Child nodes (for directories)
Parent *FileNode // Parent node
// contains filtered or unexported fields
}
FileNode represents a file or directory in the tree
func NewFileNode ¶
NewFileNode creates a new file node
func (*FileNode) GetChildren ¶
GetChildren returns a copy of all children
func (*FileNode) RemoveChild ¶
RemoveChild removes a child node
type FileTree ¶
FileTree represents the complete file system tree
func (*FileTree) GetNodeCount ¶
GetNodeCount returns the total number of nodes in the tree
func (*FileTree) IncrementNodeCount ¶
func (t *FileTree) IncrementNodeCount()
IncrementNodeCount increments the node count
type SnapshotConfig ¶
type SnapshotConfig struct {
MaxScanDepth int // Maximum directory depth to scan
IncludeHidden bool // Whether to include hidden files
ExcludePatterns []string // Glob patterns to exclude
MaxFileSize int64 // Maximum file size to track
FollowSymlinks bool // Whether to follow symbolic links
}
SnapshotConfig holds configuration for snapshot creation
type SnapshotManager ¶
type SnapshotManager struct {
// contains filtered or unexported fields
}
SnapshotManager manages file tree snapshots with size constraints
func NewSnapshotManager ¶
func NewSnapshotManager(maxNodes int, config SnapshotConfig) *SnapshotManager
NewSnapshotManager creates a new snapshot manager
func (*SnapshotManager) Cleanup ¶
func (sm *SnapshotManager) Cleanup()
Cleanup removes old snapshots to free memory
func (*SnapshotManager) ClearCurrentSnapshot ¶
func (sm *SnapshotManager) ClearCurrentSnapshot()
ClearCurrentSnapshot clears the current snapshot
func (*SnapshotManager) CreateSnapshot ¶
func (sm *SnapshotManager) CreateSnapshot(rootPath string) (*FileTree, error)
CreateSnapshot creates a new snapshot from the given root path
func (*SnapshotManager) GetCurrentSnapshot ¶
func (sm *SnapshotManager) GetCurrentSnapshot() *FileTree
GetCurrentSnapshot returns the current snapshot
func (*SnapshotManager) GetPreviousSnapshot ¶
func (sm *SnapshotManager) GetPreviousSnapshot() *FileTree
GetPreviousSnapshot returns the previous snapshot
func (*SnapshotManager) GetSnapshotStats ¶
func (sm *SnapshotManager) GetSnapshotStats() (currentNodes, previousNodes int)
GetSnapshotStats returns statistics about the snapshots
func (*SnapshotManager) HasPreviousSnapshot ¶
func (sm *SnapshotManager) HasPreviousSnapshot() bool
HasPreviousSnapshot checks if there's a previous snapshot
type TreeComparator ¶
type TreeComparator struct {
}
TreeComparator compares two file tree snapshots and detects changes
func NewTreeComparator ¶
func NewTreeComparator() *TreeComparator
NewTreeComparator creates a new tree comparator
func (*TreeComparator) CompareSnapshots ¶
func (tc *TreeComparator) CompareSnapshots(oldTree, newTree *FileTree) []*FileChange
CompareSnapshots compares two snapshots and returns detected changes
func (*TreeComparator) ConvertToFimEvents ¶
func (tc *TreeComparator) ConvertToFimEvents(changes []*FileChange, hostPath string) []fimtypes.FimEvent
ConvertToFimEvents converts file changes to FIM events