MCPcopy Create free account
hub / github.com/diffusionstudio/vits-web / writeFile

Function writeFile

src/piper.js:2837–2850  ·  view source on GitHub ↗
(path, data, opts = {})

Source from the content-addressed store, hash-verified

2835 return ret;
2836 },
2837 writeFile(path, data, opts = {}) {
2838 opts.flags = opts.flags || 577;
2839 var stream = FS.open(path, opts.flags, opts.mode);
2840 if (typeof data == 'string') {
2841 var buf = new Uint8Array(lengthBytesUTF8(data) + 1);
2842 var actualNumBytes = stringToUTF8Array(data, buf, 0, buf.length);
2843 FS.write(stream, buf, 0, actualNumBytes, undefined, opts.canOwn);
2844 } else if (ArrayBuffer.isView(data)) {
2845 FS.write(stream, data, 0, data.byteLength, undefined, opts.canOwn);
2846 } else {
2847 throw new Error('Unsupported data type');
2848 }
2849 FS.close(stream);
2850 },
2851 cwd: () => FS.currentPath,
2852 chdir(path) {
2853 var lookup = FS.lookupPath(path, { follow: true });

Callers

nothing calls this directly

Calls 2

lengthBytesUTF8Function · 0.85
stringToUTF8ArrayFunction · 0.85

Tested by

no test coverage detected