diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/library.js | 6 | ||||
-rw-r--r-- | src/library_browser.js | 24 |
2 files changed, 26 insertions, 4 deletions
diff --git a/src/library.js b/src/library.js index 6662e9b7..1bb58833 100644 --- a/src/library.js +++ b/src/library.js @@ -304,12 +304,14 @@ LibraryManager.library = { // You can also call this with a typed array instead of a url. It will then // do preloading for the Image/Audio part, as if the typed array were the // result of an XHR that you did manually. - createPreloadedFile: function(parent, name, url, canRead, canWrite, onload, onerror) { + createPreloadedFile: function(parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile) { Browser.ensureObjects(); var fullname = FS.joinPath([parent, name], true); function processData(byteArray) { function finish(byteArray) { - FS.createDataFile(parent, name, byteArray, canRead, canWrite); + if (!dontCreateFile) { + FS.createDataFile(parent, name, byteArray, canRead, canWrite); + } if (onload) onload(); removeRunDependency('cp ' + fullname); } 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; |