summaryrefslogtreecommitdiff
path: root/platform/javascript/engine
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2020-05-08 16:55:01 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2020-05-10 18:22:48 +0200
commitd2eef397312d1c142d95c2aef0ff3d5aeee6495a (patch)
tree3d5564f2769337c4eee0899d245b246e526ea542 /platform/javascript/engine
parent7411e7fd37eb169b0f0675d4e4c2ec28786aec1b (diff)
Fix Closure compiler build, python style.
Move copyToFS into utils.js library included with '--pre-js'.
Diffstat (limited to 'platform/javascript/engine')
-rw-r--r--platform/javascript/engine/engine.js6
-rw-r--r--platform/javascript/engine/utils.js18
2 files changed, 3 insertions, 21 deletions
diff --git a/platform/javascript/engine/engine.js b/platform/javascript/engine/engine.js
index aecc6b9432..d709422abb 100644
--- a/platform/javascript/engine/engine.js
+++ b/platform/javascript/engine/engine.js
@@ -82,7 +82,7 @@ Function('return this')()['Engine'] = (function() {
var me = this;
return me.init().then(function() {
if (!me.rtenv) {
- reject(new Error('The engine must be initialized before it can be started'));
+ return Promise.reject(new Error('The engine must be initialized before it can be started'));
}
if (!(me.canvas instanceof HTMLCanvasElement)) {
@@ -124,7 +124,7 @@ Function('return this')()['Engine'] = (function() {
}
return new Promise(function(resolve, reject) {
preloader.preloadedFiles.forEach(function(file) {
- Utils.copyToFS(me.rtenv['FS'], file.path, file.buffer);
+ me.rtenv['copyToFS'](file.path, file.buffer);
});
preloader.preloadedFiles.length = 0; // Clear memory
me.rtenv['callMain'](args);
@@ -217,7 +217,7 @@ Function('return this')()['Engine'] = (function() {
if (this.rtenv == null) {
throw new Error("Engine must be inited before copying files");
}
- Utils.copyToFS(this.rtenv['FS'], path, buffer);
+ this.rtenv['copyToFS'](path, buffer);
}
// Closure compiler exported engine methods.
diff --git a/platform/javascript/engine/utils.js b/platform/javascript/engine/utils.js
index fdff90a923..0c97b38199 100644
--- a/platform/javascript/engine/utils.js
+++ b/platform/javascript/engine/utils.js
@@ -27,24 +27,6 @@ var Utils = {
return instantiateWasm;
},
- copyToFS: function(fs, path, buffer) {
- var p = path.lastIndexOf("/");
- var dir = "/";
- if (p > 0) {
- dir = path.slice(0, path.lastIndexOf("/"));
- }
- try {
- fs.stat(dir);
- } catch (e) {
- if (e.errno !== 44) { // 'ENOENT', see https://github.com/emscripten-core/emscripten/blob/master/system/lib/libc/musl/arch/emscripten/bits/errno.h
- throw e;
- }
- fs['mkdirTree'](dir);
- }
- // With memory growth, canOwn should be false.
- fs['writeFile'](path, new Uint8Array(buffer), {'flags': 'wx+'});
- },
-
findCanvas: function() {
var nodes = document.getElementsByTagName('canvas');
if (nodes.length && nodes[0] instanceof HTMLCanvasElement) {