emscripten-core / emscripten-core/emscripten

Expose wasmfs_create_file to JS

Open
#23,667 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Right now there's no way for JS code to call `wasmfs_create_file` directly with a specific backend, which is a key use case for WASMFS. I suggest adding the following function to `libwasmfs.js`:

```
createFile(path, mode, backend) {
return FS.handleError(withStackSave(() => __wasmfs_create_file(module.stringToUTF8OnStack(path), mode, backend)));
}
```

We already have ways to create backends in JS code (e.g. OPFS and FETCHFS both define `createBackend`), but no way to use them apart from `FS.mount` which is unsuitable for single files.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.