forked from Hamza-Anver/Gridfinity-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilesystem.js
30 lines (26 loc) · 961 Bytes
/
filesystem.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
async function getBrowserFSLibrariesMounts(archiveNames) {
const Buffer = BrowserFS.BFSRequire('buffer').Buffer;
const fetchData = async url => (await fetch(url)).arrayBuffer();
const results = await Promise.all(archiveNames.map(async n => [n, await fetchData(`./${n}.zip`)]));
const zipMounts = {};
for (const [n, zipData] of results) {
zipMounts[n] = {
fs: "ZipFS",
options: {
zipData: Buffer.from(zipData)
}
}
}
return zipMounts;
}
async function symlinkLibraries(archiveNames, FS, prefix='/libraries', cwd='/tmp') {
const createSymlink = async (target, source) => {
// console.log('symlink', target, source);
await FS.symlink(target, source);
// await symlink(target, source);
};
await Promise.all(archiveNames.map(n => (async () => {
// removed generic symlink system and now only links named library archives
await createSymlink(`${prefix}/${n}`, `${cwd}/${n}`);
})()));
}