I needed this myself, together with a way to move files from my local HD to the root to the emscripten file system (to complete the file download/upload round trip)..
In the end I've managed to do it by looking how other projects were made (I'm not a Javascript programmer...). However, to address your question, the way I've found is to use a custom emscripten html shell that includes the file FileSaver.js available here: https://github.com/eligrey/FileSaver.js, together with some code that I call from C++. The shell file I use ends like this: <script src="FileSaver.js"> </script> > <script> > function saveFileFromMemoryFSToDisk(memoryFSname,localFSname) // > This can be called by C++ code > { > var data=FS.readFile(memoryFSname); > var blob; > var isSafari = > /^((?!chrome|android).)*safari/i.test(navigator.userAgent); > if(isSafari) { > blob = new Blob([data.buffer], {type: "application/octet-stream"}); > } else { > blob = new Blob([data.buffer], {type: "application/octet-binary"}); > } > saveAs(blob, localFSname); > } > </script> > > {{{ SCRIPT }}} </body> > </html> > Then in my C++ code I can use for example: > > emscripten_run_script("saveFileFromMemoryFSToDisk('images/image.jpg','image.jpg')"); // The second argument must be a simple filename (we can't use directories) > Hope this helps. P.S. AFAIR I copied this solution from this emscripten program here: http://webloria.loria.fr/%7Elevy/GEOGRAM/ -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
