I have C++
code that create files in local FS
, and I want to run this code in JS using Emscripten
.
My question is if it possible to create and save files from code that run by the browser on my local FS?
Is there any necessary changes I should make?
Asked
Active
Viewed 60 times
0

arii
- 143
- 2
- 12
-
This question is NOT a duplicate to the one linked. This question asks about SAVING files, the other question asks about READING files. As the other answer indicates, reading is possible as long as you indicate the file at compile time to load into the virtual file system. Saving is more tricky, and (I expect) would require JS to create a file image that the user has to manually agree to download. – Charles Ofria Dec 26 '16 at 18:58
-
`FS.readFile()` and Data URL would be useful – zakki Dec 27 '16 at 07:08
-
any example if possible? :) @zakki – arii Dec 27 '16 at 07:33
-
@CharlesOfria - tnx for that, I really didn't understand how this Q is link to the duplicate – arii Dec 27 '16 at 07:34
-
Someting like this. https://gist.github.com/zakki/b43609a219d9eed5477d87ca99ff3728 – zakki Dec 27 '16 at 09:32
-
Im not sure I understand. if I have c++ code like: `FILE *f; f=fopen("c:\","wb"); `how the JS code you shared gonna help? @zakki – arii Dec 27 '16 at 11:13
-
JavaScript in web browsers can't access local fs, so write to memfs and download it via – zakki Dec 27 '16 at 11:24
-
sorry, still not sure I got it.. but the JS code generate automaticly, how do I add this code to JS file? @zakki – arii Dec 28 '16 at 09:40
-
`EM_ASM*` in c or just ` – zakki Dec 30 '16 at 12:33