MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / getFile

Function getFile

src/lib/fileList.js:188–200  ·  view source on GitHub ↗

* Get all files in a folder * e.g /dir1/dir2/dir3 * This function will first test if dir1 exists in the tree, * if not, it will return null, otherwise it will traverse the tree * and return the files in dir3 * @param {string} path - Folder path * @param {Tree} tree - Files tree

(path, tree)

Source from the content-addressed store, hash-verified

186 * @param {Tree} tree - Files tree
187 */
188function getFile(path, tree) {
189 const { children } = tree;
190 let { url } = tree;
191 if (url === path) return tree;
192 if (!children) return null;
193 const len = children.length;
194 for (let i = 0; i < len; i++) {
195 const item = children[i];
196 const result = getFile(path, item);
197 if (result) return result;
198 }
199 return null;
200}
201
202/**
203 * Get all files

Callers 3

filesFunction · 0.70
EditorFileClass · 0.70
resolveReferenceFileFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected