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

Function readFile

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

Source from the content-addressed store, hash-verified

2572 return stream.stream_ops.ioctl(stream, cmd, arg);
2573 },
2574 readFile(path, opts = {}) {
2575 opts.flags = opts.flags || 0;
2576 opts.encoding = opts.encoding || 'binary';
2577 if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
2578 abort(`Invalid encoding type "${opts.encoding}"`);
2579 }
2580 var stream = FS.open(path, opts.flags);
2581 var stat = FS.stat(path);
2582 var length = stat.size;
2583 var buf = new Uint8Array(length);
2584 FS.read(stream, buf, 0, length, 0);
2585 if (opts.encoding === 'utf8') {
2586 buf = UTF8ArrayToString(buf);
2587 }
2588 FS.close(stream);
2589 return buf;
2590 },
2591 writeFile(path, data, opts = {}) {
2592 opts.flags = opts.flags || 577;
2593 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