aboutsummaryrefslogtreecommitdiff
path: root/src/library_browser.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-10-04 18:13:17 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-10-04 18:13:17 -0700
commit2be2720852b990937bfbe71a8f6b65b2f20cb33d (patch)
tree77dc7a0b7decbb31a2b246a3e0c252210061826b /src/library_browser.js
parent2ac61df97125086a0ecb6f00fdd08cf8d93f02c2 (diff)
emscripten_async_prepare
Diffstat (limited to 'src/library_browser.js')
-rw-r--r--src/library_browser.js24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/library_browser.js b/src/library_browser.js
index 27bf4a0c..6985e04a 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -364,14 +364,34 @@ mergeInto(LibraryManager.library, {
_file.substr(index +1),
_url, true, true,
function() {
- FUNCTION_TABLE[onload](file);
+ if (onload) FUNCTION_TABLE[onload](file);
},
function() {
- FUNCTION_TABLE[onerror](file);
+ if (onerror) FUNCTION_TABLE[onerror](file);
}
);
},
+ emscripten_async_prepare: function(file, onload, onerror) {
+ var _file = Pointer_stringify(file);
+ var data = FS.analyzePath(_file);
+ if (!data.exists) return -1;
+ var index = _file.lastIndexOf('/');
+ FS.createPreloadedFile(
+ _file.substr(0, index),
+ _file.substr(index +1),
+ new Uint8Array(data.object.contents), true, true,
+ function() {
+ if (onload) FUNCTION_TABLE[onload](file);
+ },
+ function() {
+ if (onerror) FUNCTION_TABLE[onerror](file);
+ },
+ true // don'tCreateFile - it's already there
+ );
+ return 0;
+ },
+
emscripten_async_run_script__deps: ['emscripten_run_script'],
emscripten_async_run_script: function(script, millis) {
Module['noExitRuntime'] = true;