MCPcopy Create free account
hub / github.com/microsoft/vscode-cpptools / scanFolder

Function scanFolder

Extension/src/Utility/Filesystem/find.ts:133–154  ·  view source on GitHub ↗
(folder: string, scanDepth: number, filePredicate?: (file: File) => Promise<boolean> | boolean, folderPredicate?: (folder: FolderWithChildren) => Promise<boolean> | boolean, files = accumulator<string>())

Source from the content-addressed store, hash-verified

131}
132
133export async function scanFolder(folder: string, scanDepth: number, filePredicate?: (file: File) => Promise<boolean> | boolean, folderPredicate?: (folder: FolderWithChildren) => Promise<boolean> | boolean, files = accumulator<string>()): Promise<void> {
134 // should not have depth less than 0
135 if (scanDepth < 0) {
136 return;
137 }
138
139 // normalize the folder
140 folder = normalize(folder);
141
142 // if we have already visited this folder, return
143 await foreach(readDirectory(folder), async ([_name, entry]) => {
144 if (entry.isFile) {
145 if (!filePredicate || await filePredicate(entry)) {
146 files.add(entry.fullPath);
147 }
148 return;
149 }
150 if (scanDepth && entry.isFolder && (!folderPredicate || await folderPredicate(entry))) {
151 await scanFolder(entry.fullPath, scanDepth - 1, filePredicate, folderPredicate, files);
152 }
153 });
154}
155
156/** The Finder searches paths to find executable given a name or regular expression.
157 *

Callers 1

scanMethod · 0.85

Calls 4

accumulatorFunction · 0.90
foreachFunction · 0.90
readDirectoryFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected