GP-0: Fix DummyProc.which

This commit is contained in:
Dan 2023-08-14 13:19:18 -04:00
parent db5945c286
commit c562fbad67

View File

@ -35,22 +35,29 @@ public class DummyProc implements AutoCloseable {
return Application.getOSFile(cmd).getAbsolutePath();
}
catch (Exception e) {
// probably Application is not initialized
// just try next strategy
}
// Try the build/exe/<cmd>/ and build/exe/<cmd>/<platform>/ directory
for (ResourceFile modRoot : Application.getModuleRootDirectories()) {
ResourceFile exe = new ResourceFile(modRoot, "build/exe/" + cmd + "/" + cmd);
if (exe.exists() && exe.getFile(false).canExecute()) {
return exe.getAbsolutePath();
}
ResourceFile platformExe = new ResourceFile(modRoot,
"build/exe/" + cmd + "/" + Platform.CURRENT_PLATFORM.getDirectoryName() + "/" +
cmd);
if (platformExe.exists() && platformExe.getFile(false).canExecute()) {
return platformExe.getAbsolutePath();
try {
for (ResourceFile modRoot : Application.getModuleRootDirectories()) {
ResourceFile exe = new ResourceFile(modRoot, "build/exe/" + cmd + "/" + cmd);
if (exe.exists() && exe.getFile(false).canExecute()) {
return exe.getAbsolutePath();
}
ResourceFile platformExe = new ResourceFile(modRoot,
"build/exe/" + cmd + "/" + Platform.CURRENT_PLATFORM.getDirectoryName() + "/" +
cmd);
if (platformExe.exists() && platformExe.getFile(false).canExecute()) {
return platformExe.getAbsolutePath();
}
}
}
catch (Exception e) {
// probably Application is not initialized
// just try next strategy
}
// Try the current directory
if (new File(cmd).canExecute()) {