MCPcopy Create free account
hub / github.com/cloudflare/agents / insertContent

Method insertContent

packages/shell/src/fs/in-memory-fs.ts:620–641  ·  view source on GitHub ↗
(
    rawPath: string,
    content: FileContent,
    encoding?: BufferEncoding,
    mode?: number,
    mtime?: Date
  )

Source from the content-addressed store, hash-verified

618 // ── Mutation helpers ───────────────────────────────────────────────
619
620 private insertContent(
621 rawPath: string,
622 content: FileContent,
623 encoding?: BufferEncoding,
624 mode?: number,
625 mtime?: Date
626 ): void {
627 validatePath(rawPath, "write");
628 const segs = split(normalizePath(rawPath));
629 if (segs.length === 0) {
630 throw new Error(
631 `EISDIR: illegal operation on a directory, write '${rawPath}'`
632 );
633 }
634 const parent = this.scaffold(segs);
635 parent.children.set(segs[segs.length - 1], {
636 kind: "file",
637 bytes: toBuffer(content, encoding),
638 mode: mode ?? DEFAULT_FILE_MODE,
639 mtime: mtime ?? new Date()
640 });
641 }
642
643 private insertLazy(
644 rawPath: string,

Callers 5

constructorMethod · 0.95
writeFileSyncMethod · 0.95
writeFileMethod · 0.95
writeFileBytesMethod · 0.95
appendFileMethod · 0.95

Calls 6

scaffoldMethod · 0.95
validatePathFunction · 0.90
normalizePathFunction · 0.90
toBufferFunction · 0.90
splitFunction · 0.85
setMethod · 0.65

Tested by

no test coverage detected