Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in page:Advanced APIs #23253

Open
vitonsky opened this issue Dec 25, 2024 · 3 comments
Open

Bug in page:Advanced APIs #23253

vitonsky opened this issue Dec 25, 2024 · 3 comments

Comments

@vitonsky
Copy link

vitonsky commented Dec 25, 2024

Section "Advanced File System API" have no explanation for every method.

I working on implementing my own file system, and i can't understand what to do, because documentation do not have API description.

For example i've checked MEMFS implementation and i want to understand what a FS.createNode call do, i go to https://emscripten.org/docs/api_reference/advanced-apis.html#FS.createNode but there are no any elaboration what this method do.

URL: ../../docs/api_reference/advanced-apis

image

Proposal

Explain what every method do and optionally add short description how to implement own file system and examples if possible

@kripken
Copy link
Member

kripken commented Dec 30, 2024

I agree these docs should be improved, but note that new development is focused mostly on WasmFS now. The JS APIs may be identical in some cases, but not always.

If you are writing an FS backend, perhaps it can be a WasmFS backend? Here is the MEMFS version in WasmFS:

https://github.com/emscripten-core/emscripten/blob/main/system/lib/wasmfs/backends/memory_backend.cpp

Other backends in that dir have examples of JS integration if you need that.

@vitonsky
Copy link
Author

@kripken i work on javascript app that uses Postgres compiled to WASM.

I need to implement javascript bindings for emscripten FS that would proxy my virtual FS with encryption, that is implemented in javascript.

Does cpp files related for my case?

What is WasmFS?

Currently i don't understand how FS does work in emscripten and how i can implement my own backend on JS.
Is there any documentation about it or plans to add documentation?

@kripken
Copy link
Member

kripken commented Dec 30, 2024

An overview of WasmFS is here:

https://emscripten.org/docs/api_reference/Filesystem-API.html#new-file-system-wasmfs

It is basically stable, but not yet feature complete (I'm updating the docs on that now).

You can implement JS bindings in WasmFS, so I think it is relevant for you. Here is a simple JS File backend:

https://github.com/emscripten-core/emscripten/blob/main/src/library_wasmfs_js_file.js

(C++ side is minimal: https://github.com/emscripten-core/emscripten/blob/main/system/lib/wasmfs/backends/js_file_backend.cpp)

That is a simple example, but see the OPFS backend (alongside those files) for a very detailed and sophisticated one.

Documentation could definitely be better, but reading the simple backends like JS File should be helpful. That is what I do when I write a backend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants