2024-01-11 23:52:22 +03:00
|
|
|
package walk
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
2024-01-12 14:33:14 +03:00
|
|
|
type filesystemWalker struct {
|
2024-01-11 23:52:22 +03:00
|
|
|
root string
|
|
|
|
}
|
|
|
|
|
2024-01-12 14:33:14 +03:00
|
|
|
func (f filesystemWalker) Root() string {
|
2024-01-11 23:52:22 +03:00
|
|
|
return f.root
|
|
|
|
}
|
|
|
|
|
2024-01-12 14:33:14 +03:00
|
|
|
func (f filesystemWalker) Walk(_ context.Context, fn filepath.WalkFunc) error {
|
2024-01-11 23:52:22 +03:00
|
|
|
return filepath.Walk(f.root, fn)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewFilesystem(root string) (Walker, error) {
|
2024-01-12 14:33:14 +03:00
|
|
|
return filesystemWalker{root}, nil
|
2024-01-11 23:52:22 +03:00
|
|
|
}
|