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

Function FS_preloadFile

sqlite-wasm-cos/sqlite3-node.mjs:1425–1446  ·  view source on GitHub ↗
(parent, name, url, canRead, canWrite, dontCreateFile, canOwn, preFinish)

Source from the content-addressed store, hash-verified

1423 return byteArray;
1424 };
1425 var FS_preloadFile = async (parent, name, url, canRead, canWrite, dontCreateFile, canOwn, preFinish) => {
1426 // TODO we should allow people to just pass in a complete filename instead
1427 // of parent and name being that we just join them anyways
1428 var fullname = name ? PATH_FS.resolve(PATH.join2(parent, name)) : parent;
1429 var dep = getUniqueRunDependency(`cp ${fullname}`); // might have several active requests for the same fullname
1430 addRunDependency(dep);
1431
1432 try {
1433 var byteArray = url;
1434 if (typeof url == 'string') {
1435 byteArray = await asyncLoad(url);
1436 }
1437
1438 byteArray = await FS_handledByPreloadPlugin(byteArray, fullname);
1439 preFinish?.();
1440 if (!dontCreateFile) {
1441 FS_createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);
1442 }
1443 } finally {
1444 removeRunDependency(dep);
1445 }
1446 };
1447 var FS_createPreloadedFile = (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) => {
1448 FS_preloadFile(parent, name, url, canRead, canWrite, dontCreateFile, canOwn, preFinish).then(onload).catch(onerror);
1449 };

Callers 1

FS_createPreloadedFileFunction · 0.70

Calls 6

getUniqueRunDependencyFunction · 0.70
addRunDependencyFunction · 0.70
asyncLoadFunction · 0.70
FS_createDataFileFunction · 0.70
removeRunDependencyFunction · 0.70

Tested by

no test coverage detected