MCPcopy Create free account
hub / github.com/GoogleChrome/samples / readFile

Function readFile

sqlite-wasm-cos/sqlite3.mjs:2695–2711  ·  view source on GitHub ↗
(path, opts = {})

Source from the content-addressed store, hash-verified

2693 return stream.stream_ops.ioctl(stream, cmd, arg);
2694 },
2695 readFile(path, opts = {}) {
2696 opts.flags = opts.flags || 0;
2697 opts.encoding = opts.encoding || 'binary';
2698 if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
2699 abort(`Invalid encoding type "${opts.encoding}"`);
2700 }
2701 var stream = FS.open(path, opts.flags);
2702 var stat = FS.stat(path);
2703 var length = stat.size;
2704 var buf = new Uint8Array(length);
2705 FS.read(stream, buf, 0, length, 0);
2706 if (opts.encoding === 'utf8') {
2707 buf = UTF8ArrayToString(buf);
2708 }
2709 FS.close(stream);
2710 return buf;
2711 },
2712 writeFile(path, data, opts = {}) {
2713 opts.flags = opts.flags || 577;
2714 var stream = FS.open(path, opts.flags, opts.mode);

Callers

nothing calls this directly

Calls 5

abortFunction · 0.70
UTF8ArrayToStringFunction · 0.70
openMethod · 0.45
readMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected