On Thursday, 2 May 2019 01:52:21 UTC+2, Zajo wrote:
Is there any way to open files hosted on a web server and read them
> synchronously on demand
>
If it helps we lazily load files into Emscripten's MEMFS. For example,
create the in-memory file system with some help from JavaScript:
EM_JS(bool, myMount, (const char* mnt), {
var _mnt = UTF8ToString(mnt);
if (_mnt) {
try {
if (FS.mount(MEMFS, {}, _mnt)) {
return true;
}
} catch (e) {}
}
return false;
}
if (::mkdir("/myFiles", S_IRWXUGO) == 0) {
myMount("/myFiles");
}
Then load a file into it with one of the wget calls
<https://emscripten.org/docs/api_reference/emscripten.h.html#emscripten-asynchronous-file-system-api>,
supplying your own success and failure callbacks:
emscripten_async_wget("http://example.com/myText.txt", "/myFiles/myText.txt"
, loadedCallback, failureCallback);
You can then read these local MEMFS files with the regular fopen, etc.
--
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.