@@ -15,13 +15,7 @@ type TreeNode struct {
1515 Children []* TreeNode `json:"children,omitempty"`
1616}
1717
18- func DirectoryTree (path string , isPathAllowed func (string ) error , shouldIgnore func (string ) bool , maxItems int ) (* TreeNode , error ) {
19- itemCount := 0
20- return directoryTree (context .Background (), path , isPathAllowed , shouldIgnore , maxItems , & itemCount )
21- }
22-
23- // DirectoryTreeWithContext is a context-aware version of DirectoryTree.
24- func DirectoryTreeWithContext (ctx context.Context , path string , isPathAllowed func (string ) error , shouldIgnore func (string ) bool , maxItems int ) (* TreeNode , error ) {
18+ func DirectoryTree (ctx context.Context , path string , isPathAllowed func (string ) error , shouldIgnore func (string ) bool , maxItems int ) (* TreeNode , error ) {
2519 itemCount := 0
2620 return directoryTree (ctx , path , isPathAllowed , shouldIgnore , maxItems , & itemCount )
2721}
@@ -87,17 +81,6 @@ func directoryTree(ctx context.Context, path string, isPathAllowed func(string)
8781 return node , nil
8882}
8983
90- func ListDirectory (path string , shouldIgnore func (string ) bool ) ([]string , error ) {
91- tree , err := DirectoryTree (path , func (string ) error { return nil }, shouldIgnore , 0 )
92- if err != nil {
93- return nil , err
94- }
95-
96- var files []string
97- CollectFilesFromTree (tree , "" , & files )
98- return files , nil
99- }
100-
10184// CollectFilesFromTree recursively collects file paths from a DirectoryTree.
10285// Pass basePath="" for relative paths, or a parent directory for absolute paths.
10386func CollectFilesFromTree (node * TreeNode , basePath string , files * []string ) {
0 commit comments