diff options
| author | Leon Krause | 2018-03-27 09:14:03 +0200 |
|---|---|---|
| committer | Leon Krause | 2018-03-27 11:26:25 +0200 |
| commit | 6f1bddf4b5e6716f59bcbd9a7587b6d556251ef9 (patch) | |
| tree | 4b8e06d9b4ff816817c10fd196cf00e3fff486f0 | |
| parent | 63c7fc6358343c3de6cfaa40436063646eb8b7a1 (diff) | |
| download | godot-6f1bddf4b5e6716f59bcbd9a7587b6d556251ef9.tar.gz godot-6f1bddf4b5e6716f59bcbd9a7587b6d556251ef9.tar.zst godot-6f1bddf4b5e6716f59bcbd9a7587b6d556251ef9.zip | |
| -rw-r--r-- | platform/javascript/engine.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/platform/javascript/engine.js b/platform/javascript/engine.js index c54ccef1e..d0d01b03a 100644 --- a/platform/javascript/engine.js +++ b/platform/javascript/engine.js @@ -1,3 +1,4 @@ + exposedLibs['PATH'] = PATH; exposedLibs['FS'] = FS; return Module; }, @@ -96,14 +97,14 @@ } if (pathOrBuffer instanceof Uint8Array) { preloadedFiles.push({ - name: bufferFilename, + path: bufferFilename, buffer: pathOrBuffer }); return Promise.resolve(); } else if (typeof pathOrBuffer === 'string') { return loadPromise(pathOrBuffer, preloadProgressTracker).then(function(xhr) { preloadedFiles.push({ - name: pathOrBuffer, + path: pathOrBuffer, buffer: xhr.response }); }); @@ -166,7 +167,16 @@ this.rtenv.thisProgram = executableName || getBaseName(basePath); preloadedFiles.forEach(function(file) { - LIBS.FS.createDataFile('/', file.name, new Uint8Array(file.buffer), true, true, true); + var dir = LIBS.PATH.dirname(file.path); + try { + LIBS.FS.stat(dir); + } catch (e) { + if (e.code !== 'ENOENT') { + throw e; + } + LIBS.FS.mkdirTree(dir); + } + LIBS.FS.createDataFile('/', file.path, new Uint8Array(file.buffer), true, true, true); }, this); preloadedFiles = null; |
