MCPcopy Create free account
hub / github.com/bewcloud/bewcloud / getFilePaths

Function getFilePaths

lib/utils/webdav.ts:112–155  ·  view source on GitHub ↗
(
  path: string,
  depth?: number | null,
)

Source from the content-addressed store, hash-verified

110}
111
112async function getFilePaths(
113 path: string,
114 depth?: number | null,
115): Promise<string[]> {
116 const filePaths: string[] = [];
117
118 try {
119 const stat = await Deno.stat(path);
120
121 if (stat.isFile) {
122 filePaths.push(path);
123 } else if (stat.isDirectory || stat.isSymlink) {
124 if (depth === 0) {
125 filePaths.push(`${path}/`);
126 } else {
127 filePaths.push(`${path}/`);
128
129 const directoryEntries = Deno.readDir(path);
130
131 for await (const entry of directoryEntries) {
132 const entryPath = [path, entry.name]
133 .filter(Boolean)
134 .join('/')
135 .replaceAll('//', '/');
136
137 filePaths.push(entry.isDirectory || entry.isSymlink ? `${entryPath}/` : entryPath);
138
139 if (entry.isDirectory && (depth === 1 || depth === null)) {
140 const nestedResources = await getFilePaths(
141 entryPath,
142 depth ? depth - 1 : depth,
143 );
144
145 filePaths.push(...nestedResources);
146 }
147 }
148 }
149 }
150 } catch (error) {
151 console.error(error);
152 }
153
154 return [...new Set(filePaths)];
155}
156
157export async function buildPropFindResponse(
158 properties: string[],

Callers 1

buildPropFindResponseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected