MCPcopy Create free account
hub / github.com/Kitware/VTK / getFiles

Function getFiles

Examples/Emscripten/Cxx/GeometryViewer/web/openDirectory.js:29–54  ·  view source on GitHub ↗
(dirHandle, path = dirHandle.name)

Source from the content-addressed store, hash-verified

27
28 // Recursive function that walks the directory structure.
29 const getFiles = async (dirHandle, path = dirHandle.name) => {
30 const dirs = [];
31 const files = [];
32 for await (const entry of dirHandle.values()) {
33 const nestedPath = `${path}/${entry.name}`;
34 if (entry.kind === "file") {
35 files.push(
36 entry.getFile().then((file) => {
37 file.directoryHandle = dirHandle;
38 file.handle = entry;
39 return Object.defineProperty(file, "webkitRelativePath", {
40 configurable: true,
41 enumerable: true,
42 get: () => nestedPath,
43 });
44 })
45 );
46 } else if (entry.kind === "directory") {
47 dirs.push(getFiles(entry, nestedPath));
48 }
49 }
50 return [
51 ...(await Promise.all(dirs)).flat(),
52 ...(await Promise.all(files)),
53 ];
54 };
55
56 try {
57 // Open the directory.

Callers 1

openDirectoryFunction · 0.70

Calls 3

valuesMethod · 0.45
pushMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected