()
| 84 | this.writeFile("/home/web_user/retroarch/userdata/config/" + this.EJS.defaultCoreOpts.file, output); |
| 85 | } |
| 86 | loadExternalFiles() { |
| 87 | return new Promise(async (resolve, reject) => { |
| 88 | if (this.EJS.config.externalFiles && this.EJS.config.externalFiles.constructor.name === "Object") { |
| 89 | for (const key in this.EJS.config.externalFiles) { |
| 90 | await new Promise(done => { |
| 91 | this.EJS.downloadFile(this.EJS.config.externalFiles[key], null, true, { responseType: "arraybuffer", method: "GET" }).then(async (res) => { |
| 92 | if (res === -1) { |
| 93 | if (this.EJS.debug) console.warn("Failed to fetch file from '" + this.EJS.config.externalFiles[key] + "'. Make sure the file exists."); |
| 94 | return done(); |
| 95 | } |
| 96 | let path = key; |
| 97 | if (key.trim().endsWith("/")) { |
| 98 | const invalidCharacters = /[#<$+%>!`&*'|{}/\\?"=@:^\r\n]/ig; |
| 99 | let name = this.EJS.config.externalFiles[key].split("/").pop().split("#")[0].split("?")[0].replace(invalidCharacters, "").trim(); |
| 100 | if (!name) return done(); |
| 101 | const files = await this.EJS.checkCompression(new Uint8Array(res.data), this.EJS.localization("Decompress Game Assets")); |
| 102 | if (files["!!notCompressedData"]) { |
| 103 | path += name; |
| 104 | } else { |
| 105 | for (const k in files) { |
| 106 | this.writeFile(path + k, files[k]); |
| 107 | } |
| 108 | return done(); |
| 109 | } |
| 110 | } |
| 111 | try { |
| 112 | this.writeFile(path, res.data); |
| 113 | } catch(e) { |
| 114 | if (this.EJS.debug) console.warn("Failed to write file to '" + path + "'. Make sure there are no conflicting files."); |
| 115 | } |
| 116 | done(); |
| 117 | }); |
| 118 | }) |
| 119 | } |
| 120 | } |
| 121 | resolve(); |
| 122 | }); |
| 123 | } |
| 124 | writeFile(path, data) { |
| 125 | const parts = path.split("/"); |
| 126 | let current = "/"; |
no test coverage detected