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

Function fileRead

frontend/preview/mock/mockfilesystem.ts:454–473  ·  view source on GitHub ↗
(data: FileData)

Source from the content-addressed store, hash-verified

452 return toFileInfo(entry);
453 };
454 const fileRead = async (data: FileData): Promise<FileData> => {
455 const info = await fileInfo(data);
456 if (info.notfound) {
457 return { info };
458 }
459 const entry = getEntry(info.path);
460 if (entry.isdir) {
461 const childEntries = (childrenByDir.get(entry.path) ?? []).map((child) => toFileInfo(child));
462 return { info, entries: childEntries };
463 }
464 if (entry.content == null || entry.content.byteLength === 0) {
465 return { info };
466 }
467 const { offset, end } = getReadRange(data, entry.content.byteLength);
468 return {
469 info,
470 data64: arrayToBase64(entry.content.slice(offset, end)),
471 at: { offset, size: end - offset },
472 };
473 };
474 const fileList = async (data: FileListData): Promise<FileInfo[]> => {
475 const dirPath = normalizeMockPath(data?.path ?? MockHomePath);
476 const entry = getEntry(dirPath);

Callers

nothing calls this directly

Calls 6

arrayToBase64Function · 0.90
fileInfoFunction · 0.85
getEntryFunction · 0.85
toFileInfoFunction · 0.85
getReadRangeFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected