MCPcopy
hub / github.com/jvilk/BrowserFS / writeFileSync

Method writeFileSync

src/core/file_system.ts:714–726  ·  view source on GitHub ↗
(fname: string, data: any, encoding: string | null, flag: FileFlag, mode: number)

Source from the content-addressed store, hash-verified

712 });
713 }
714 public writeFileSync(fname: string, data: any, encoding: string | null, flag: FileFlag, mode: number): void {
715 // Get file.
716 const fd = this.openSync(fname, flag, mode);
717 try {
718 if (typeof data === 'string') {
719 data = Buffer.from(data, encoding!);
720 }
721 // Write into file.
722 fd.writeSync(data, 0, data.length, 0);
723 } finally {
724 fd.closeSync();
725 }
726 }
727 public appendFile(fname: string, data: any, encoding: string | null, flag: FileFlag, mode: number, cb: BFSOneArgCallback): void {
728 // Wrap cb in file closing code.
729 const oldCb = cb;

Callers

nothing calls this directly

Calls 3

openSyncMethod · 0.95
writeSyncMethod · 0.65
closeSyncMethod · 0.65

Tested by

no test coverage detected