diff options
author | Anthony Pesch <inolen@gmail.com> | 2013-08-06 18:26:11 -0700 |
---|---|---|
committer | Anthony Pesch <inolen@gmail.com> | 2013-08-06 22:32:44 -0700 |
commit | d6cde3066305358ad1b0f074eedc0b307774ce72 (patch) | |
tree | 4d4a48795898286e1e40bca47747ee0543dd3508 /src | |
parent | a7c0536ab3c599772f37a7a6d5d0d012f5eb4055 (diff) |
store preloaded images by their absolute path
Diffstat (limited to 'src')
-rw-r--r-- | src/library.js | 4 | ||||
-rw-r--r-- | src/library_browser.js | 13 | ||||
-rw-r--r-- | src/library_sdl.js | 8 |
3 files changed, 11 insertions, 14 deletions
diff --git a/src/library.js b/src/library.js index f48220bb..a73d4dc9 100644 --- a/src/library.js +++ b/src/library.js @@ -874,7 +874,9 @@ LibraryManager.library = { // result of an XHR that you did manually. createPreloadedFile: function(parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile) { Browser.init(); - var fullname = FS.joinPath([parent, name], true); + // TODO we should allow people to just pass in a complete filename instead + // of parent and name being that we just join them anyways + var fullname = PATH.resolve(PATH.join(parent, name)); function processData(byteArray) { function finish(byteArray) { if (!dontCreateFile) { diff --git a/src/library_browser.js b/src/library_browser.js index 0db2cc44..4a322a54 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -3,6 +3,7 @@ // Utilities for browser environments mergeInto(LibraryManager.library, { + $Browser__deps: ['$PATH'], $Browser__postset: 'Module["requestFullScreen"] = function(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };\n' + // exports 'Module["requestAnimationFrame"] = function(func) { Browser.requestAnimationFrame(func) };\n' + 'Module["pauseMainLoop"] = function() { Browser.mainLoop.pause() };\n' + @@ -545,10 +546,9 @@ mergeInto(LibraryManager.library, { emscripten_async_wget: function(url, file, onload, onerror) { var _url = Pointer_stringify(url); var _file = Pointer_stringify(file); - var index = _file.lastIndexOf('/'); FS.createPreloadedFile( - _file.substr(0, index), - _file.substr(index +1), + PATH.dirname(_file), + PATH.basename(_file), _url, true, true, function() { if (onload) Runtime.dynCall('vi', onload, [file]); @@ -623,10 +623,9 @@ mergeInto(LibraryManager.library, { 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), + PATH.dirname(_file), + PATH.basename(_file), new Uint8Array(data.object.contents), true, true, function() { if (onload) Runtime.dynCall('vi', onload, [file]); @@ -646,7 +645,7 @@ mergeInto(LibraryManager.library, { var cname = _malloc(name.length+1); writeStringToMemory(name, cname); FS.createPreloadedFile( - '', + '/', name, {{{ makeHEAPView('U8', 'data', 'data + size') }}}, true, true, diff --git a/src/library_sdl.js b/src/library_sdl.js index 80c7ac07..e46b41f5 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -10,7 +10,7 @@ // or otherwise). var LibrarySDL = { - $SDL__deps: ['$FS', '$Browser'], + $SDL__deps: ['$FS', '$PATH', '$Browser'], $SDL: { defaults: { width: 320, @@ -1291,11 +1291,7 @@ var LibrarySDL = { } if (!raw) { - filename = FS.standardizePath(filename); - if (filename[0] == '/') { - // Convert the path to relative - filename = filename.substr(1); - } + filename = PATH.resolve(filename); var raw = Module["preloadedImages"][filename]; if (!raw) { if (raw === null) Module.printErr('Trying to reuse preloaded image, but freePreloadedMediaOnUse is set!'); |