Skip to content

Commit

Permalink
[neko] fix Sys.programPath() in nekotools booted exe (close #5708)
Browse files Browse the repository at this point in the history
  • Loading branch information
andyli committed Jun 19, 2017
1 parent 3d4e2be commit 0699be3
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions std/neko/_std/Sys.hx
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,27 @@
// It has to be initialized before any call to loadModule or Sys.setCwd()...
private static var sys_program_path = {
var m = neko.vm.Module.local().name;
try {
sys.FileSystem.fullPath(m);
} catch (e:Dynamic) {
// maybe the neko module name was supplied without .n extension...
if (!StringTools.endsWith(m, ".n")) {
try {
sys.FileSystem.fullPath(m + ".n");
} catch (e:Dynamic) {
if (m == "") { // it is likely neko embedded in an exe
var exe = new String(sys_exe_path());
try {
sys.FileSystem.fullPath(exe);
} catch (e:Dynamic) {
exe;
}
} else {
try {
sys.FileSystem.fullPath(m);
} catch (e:Dynamic) {
// maybe the neko module name was supplied without .n extension...
if (!StringTools.endsWith(m, ".n")) {
try {
sys.FileSystem.fullPath(m + ".n");
} catch (e:Dynamic) {
m;
}
} else {
m;
}
} else {
m;
}
}
}
Expand Down

0 comments on commit 0699be3

Please sign in to comment.