Browse Source

[neko] fix Sys.programPath() in nekotools booted exe (close #5708)

Andy Li 8 years ago
parent
commit
0699be3762
1 changed files with 19 additions and 10 deletions
  1. 19 10
      std/neko/_std/Sys.hx

+ 19 - 10
std/neko/_std/Sys.hx

@@ -163,18 +163,27 @@
 	// It has to be initialized before any call to loadModule or Sys.setCwd()...
 	// It has to be initialized before any call to loadModule or Sys.setCwd()...
 	private static var sys_program_path = {
 	private static var sys_program_path = {
 		var m = neko.vm.Module.local().name;
 		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;
 					m;
 				}
 				}
-			} else {
-				m;
 			}
 			}
 		}
 		}
 	}
 	}