MCPcopy Index your code
hub / github.com/jvilk/BrowserFS / appendFile

Method appendFile

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

Source from the content-addressed store, hash-verified

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;
730 this.open(fname, flag, mode, function(err: ApiError, fd?: File) {
731 if (err) {
732 return cb(err);
733 }
734 cb = function(err: ApiError) {
735 fd!.close(function(err2: any) {
736 oldCb(err ? err : err2);
737 });
738 };
739 if (typeof data === 'string') {
740 data = Buffer.from(data, encoding!);
741 }
742 fd!.write(data, 0, data.length, null, cb);
743 });
744 }
745 public appendFileSync(fname: string, data: any, encoding: string | null, flag: FileFlag, mode: number): void {
746 const fd = this.openSync(fname, flag, mode);
747 try {

Callers

nothing calls this directly

Calls 4

openMethod · 0.95
cbFunction · 0.85
closeMethod · 0.65
writeMethod · 0.65

Tested by

no test coverage detected