Extract & Instantiate embedded file structure from WebAssembly.
- [x] Emscripten SDK
- [ ] Go
$ npm i wasm-fs
or
$ yarn add wasm-fs
$ emcc hello.c -s STANDALONE_WASM -o hello.html --embed-file embedded_file
$ emcc hello.c -s STANDALONE_WASM -o hello.html --embed-file embedded_dir
import fs from "fs";
import { resolve } from "path";
import WASMFileSystem from "wasm-fs";
(async () => {
const wasmFileSystem = await WASMFileSystem.from(
fs.readFileSync(resolve(__dirname, "hello.wasm"))
);
console.log("root:", wasmFileSystem.root);
const testDirectory = wasmFileSystem.root.getChild("testDirectory");
console.log("testDirectory:", testDirectory);
fs.writeFileSync(
"./image.png",
testDirectory.getFile("testImage.png").content
);
})();
Not Implemented Yet.
MIT License
Copyright (c) 2023 이승훈