#include <stdio.h>
int main ()
{
FILE * pFile;
pFile = fopen ("c:\myfile.txt","w");
if (pFile!=NULL)
{
fputs ("hey",pFile);
fclose (pFile);
}
return 0;
}<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>
emscripten_run_script("saveFileFromMemoryFSToDisk('images/image.jpg','image.jpg')");
// The second argument must be a simple filename (we can't use directories)
I'm not sure I understand the part of the HTML and JS and how I handle everything together?should I run it after the c++ end?
there is somewhere I find the whole code?
Have you solved it ?
--
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 emscripten-discuss+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Btw if one is using the emrun tool to automate debugging runs, there is a special runtime function "emrun_file_dump(filename, data)" which allows one to programmatically dump a file out to local hard drive. This can make creating test harnesses easier, although it's not a feature for end user scenarios.