MCPcopy Index your code
hub / github.com/EmulatorJS/EmulatorJS / downloadRom

Method downloadRom

data/src/emulator.js:777–915  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

775 });
776 }
777 downloadRom() {
778 const supportsExt = (ext) => {
779 const core = this.getCore();
780 if (!this.extensions) return false;
781 return this.extensions.includes(ext);
782 };
783
784 return new Promise(resolve => {
785 this.textElem.innerText = this.localization("Download Game Data");
786
787 const gotGameData = (data) => {
788 if (["arcade", "mame"].includes(this.getCore(true))) {
789 this.fileName = this.getBaseFileName(true);
790 this.gameManager.FS.writeFile(this.fileName, new Uint8Array(data));
791 resolve();
792 return;
793 }
794
795 const altName = this.getBaseFileName(true);
796
797 let disableCue = false;
798 if (["pcsx_rearmed", "genesis_plus_gx", "picodrive", "mednafen_pce", "smsplus", "vice_x64", "vice_x64sc", "vice_x128", "vice_xvic", "vice_xplus4", "vice_xpet", "puae"].includes(this.getCore()) && this.config.disableCue === undefined) {
799 disableCue = true;
800 } else {
801 disableCue = this.config.disableCue;
802 }
803
804 let fileNames = [];
805 this.checkCompression(new Uint8Array(data), this.localization("Decompress Game Data"), (fileName, fileData) => {
806 if (fileName.includes("/")) {
807 const paths = fileName.split("/");
808 let cp = "";
809 for (let i = 0; i < paths.length - 1; i++) {
810 if (paths[i] === "") continue;
811 cp += `/${paths[i]}`;
812 if (!this.gameManager.FS.analyzePath(cp).exists) {
813 this.gameManager.FS.mkdir(cp);
814 }
815 }
816 }
817 if (fileName.endsWith("/")) {
818 this.gameManager.FS.mkdir(fileName);
819 return;
820 }
821 if (fileName === "!!notCompressedData") {
822 this.gameManager.FS.writeFile(altName, fileData);
823 fileNames.push(altName);
824 } else {
825 this.gameManager.FS.writeFile(`/${fileName}`, fileData);
826 fileNames.push(fileName);
827 }
828 }).then(() => {
829 let isoFile = null;
830 let supportedFile = null;
831 let cueFile = null;
832 let selectedCueExt = null;
833 fileNames.forEach(fileName => {
834 const ext = fileName.split(".").pop().toLowerCase();

Callers 1

downloadFilesMethod · 0.95

Calls 3

localizationMethod · 0.95
downloadFileMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected