MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / buildEntries

Function buildEntries

frontend/preview/mock/mockfilesystem.ts:322–369  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

320}
321
322function buildEntries(): Map<string, MockFsEntry> {
323 const inputs = createMockFilesystemEntries();
324 const entries = new Map<string, MockFsEntry>();
325 const ensureDir = (path: string) => {
326 const normalizedPath = normalizeMockPath(path, "/");
327 if (entries.has(normalizedPath)) {
328 return;
329 }
330 const dir = getDirName(normalizedPath);
331 if (normalizedPath !== "/") {
332 ensureDir(dir);
333 }
334 entries.set(normalizedPath, {
335 path: normalizedPath,
336 dir: normalizedPath === "/" ? "/" : dir,
337 name: normalizedPath === "/" ? "/" : getBaseName(normalizedPath),
338 isdir: true,
339 mimetype: MockDirMimeType,
340 modtime: MockBaseModTime + entries.size * 60000,
341 mode: MockDirMode,
342 size: 0,
343 supportsmkdir: true,
344 });
345 };
346 for (const input of inputs) {
347 const normalizedPath = normalizeMockPath(input.path, "/");
348 const isdir = input.isdir ?? false;
349 const dir = getDirName(normalizedPath);
350 if (normalizedPath !== "/") {
351 ensureDir(dir);
352 }
353 const content = input.content == null ? undefined : makeContentBytes(input.content);
354 entries.set(normalizedPath, {
355 path: normalizedPath,
356 dir: normalizedPath === "/" ? "/" : dir,
357 name: normalizedPath === "/" ? "/" : getBaseName(normalizedPath),
358 isdir,
359 mimetype: input.mimetype ?? getMimeType(normalizedPath, isdir),
360 modtime: MockBaseModTime + entries.size * 60000,
361 mode: isdir ? MockDirMode : MockFileMode,
362 size: content?.byteLength ?? 0,
363 readonly: input.readonly,
364 supportsmkdir: isdir,
365 content,
366 });
367 }
368 return entries;
369}
370
371function toFileInfo(entry: MockFsEntry): FileInfo {
372 return {

Callers 1

makeMockFilesystemFunction · 0.85

Calls 8

normalizeMockPathFunction · 0.85
getDirNameFunction · 0.85
ensureDirFunction · 0.85
makeContentBytesFunction · 0.85
getBaseNameFunction · 0.85
getMimeTypeFunction · 0.85
setMethod · 0.80

Tested by

no test coverage detected