MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / doOpenFileCallback

Method doOpenFileCallback

tools/mcsim/main.js:492–515  ·  view source on GitHub ↗
(application, path)

Source from the content-addressed store, hash-verified

490 system.openFile({ prompt:"Open File", path:system.documentsDirectory }, path => { if (path) application.defer("doOpenFileCallback", new String(path)); });
491 }
492 doOpenFileCallback(application, path) {
493 let extension = (system.platform == "win") ? ".dll" : ".so";
494 if (path.endsWith(extension)) {
495 this.quitScreen();
496 const devices = this.devices;
497 if (devices.length > 0) {
498 let index = devices.findIndex(device => device.applicationFilter.test(path));
499 if (index < 0) index = 0;
500 if (index != this.deviceIndex)
501 this.selectDevice(application, index);
502 }
503 this.libraryPath = path;
504 this.launchScreen();
505 }
506 if (path.endsWith(".xsa")) {
507 this.quitScreen();
508 this.archivePath = path;
509 const directory = system.getPathDirectory(path);
510 path = system.buildPath(directory, "mc.ffi", extension.slice(1));
511 if (system.fileExists(path))
512 this.ffiPath = path;
513 this.launchScreen();
514 }
515 }
516 doReloadFile() {
517 this.quitScreen();
518 this.launchScreen();

Callers 1

onOpenFileCallbackMethod · 0.95

Calls 6

quitScreenMethod · 0.95
selectDeviceMethod · 0.95
launchScreenMethod · 0.95
testMethod · 0.80
findIndexMethod · 0.65
sliceMethod · 0.65

Tested by

no test coverage detected