MCPcopy Create free account
hub / github.com/cloudflare/computer / writeFile

Function writeFile

packages/dofs/src/fs/writeFile.ts:115–128  ·  view source on GitHub ↗
(
  db: Database,
  path: string,
  content: WriteFileContent,
  options: WriteFileOptions,
  now: () => number,
)

Source from the content-addressed store, hash-verified

113}
114
115export async function writeFile(
116 db: Database,
117 path: string,
118 content: WriteFileContent,
119 options: WriteFileOptions,
120 now: () => number,
121): Promise<void> {
122 if (content instanceof ReadableStream) {
123 await writeFileStreaming(db, path, content, options, now);
124 return;
125 }
126 const bytes = await materialize(content);
127 writeFileSync(db, path, bytes, options, now);
128}
129
130// Streaming write path. Reads the source one source-chunk at a time,
131// re-windows into fixed CHUNK_SIZE pieces, hashes each window, and

Callers 15

gc.test.tsFile · 0.70
find.test.tsFile · 0.70
writeFileMethod · 0.70
readFile.test.tsFile · 0.70
ls.test.tsFile · 0.70
rm.test.tsFile · 0.70
grep.test.tsFile · 0.70
readdir.test.tsFile · 0.70
writeFile.test.tsFile · 0.70
symlink.test.tsFile · 0.70
fetch.test.tsFile · 0.50

Calls 3

writeFileStreamingFunction · 0.85
writeFileSyncFunction · 0.85
materializeFunction · 0.70

Tested by 1

applyFunction · 0.40