How can i configure Qt Webassembly to use emscripten's file system api?
-
Hi, want my app to use indexedDB to store data inetween sessions, and in order to use it i have to explicitly enable it inside emscripten configuration. However, i have no idea how to actually do that using QT. The documentation says i should use "-lidbfs.js" to enable it, but i don't know where exactly should i put that line. Can someone please advise me how to do that?
-
Are you using qmake or cmake?
This presumes you have a javascript script that pre-mounts the filesystem, such as:
https://codereview.qt-project.org/c/qt/qtbase/+/301981/3/src/plugins/platforms/wasm/presettings.jsqmake, in your .pro file:
QMAKE_LFLAGS += -s FORCE_FILESYSTEM=1 --pre-js presettings.js -lidbfs.js
cmake, in CMakeFIles.txt:
target_link_libraries(<put target name here> PRIVATE idbfs.js)
target_link_options(<put target name here> PRIVATE --pre-js presettings.js)
target_link_options(<put target name here> PRIVATE "SHELL:-s FORCE_FILESYSTEM=1 ")Change <put target name here> to what ever your apps 'target' name is.
-
Thanks a lot for help, but something still seems to be working incorrectly. I am trying to use EM_ASM to use the code directly in my cpp file like this
EM_ASM( FS.mkdir('/src'); FS.mount(IDBFS, {}, '/src'); FS.syncfs(true, function (err) { }); );
However, the project refuses to build due to "use of undeclared identifier FS", apparently not recognizing the macro for what it is. If i do it using the js script you mentioned, does it mean i will now be able to interact with "/home/web_user/.config" file normally using
file.open(QIODevice::ReadWrite);
Or is there some other way i can access it inside my code
-
Maybe you need to add #include <emscripten.h>
Yes, that script is for QSettings, but you could put /src in there as well.