Skip to content

Commit

Permalink
Fix "Cannot run program" in engine setting on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiraoka committed Jan 14, 2023
1 parent b946340 commit 1cacd75
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/featurecat/lizzie/gui/ConfigDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -1838,8 +1838,7 @@ private String getEngineLine() {
if (result == JFileChooser.APPROVE_OPTION) {
engineFile = chooser.getSelectedFile();
if (engineFile != null) {
enginePath = engineFile.getAbsolutePath();
enginePath = relativizePath(engineFile.toPath(), this.curPath);
enginePath = relativizePath(engineFile.toPath(), this.curPath, true);
getCommandHelp();
JFileChooser chooserw = new JFileChooser(".");
chooserw.setMultiSelectionEnabled(false);
Expand Down Expand Up @@ -1883,12 +1882,20 @@ private String getImagePath() {
}

private String relativizePath(Path path, Path curPath) {
return relativizePath(path, curPath, false);
}

private String relativizePath(Path path, Path curPath, Boolean isCommand) {
Path relatPath;
if (path.startsWith(curPath)) {
relatPath = curPath.relativize(path);
} else {
relatPath = path;
}
if (isCommand && relatPath.getFileName().equals(relatPath) && !isWindows()) {
// "leelaz" ==> "./leelaz" for Linux
relatPath = (new File(".")).toPath().resolve(relatPath);
}
return relatPath.toString();
}

Expand Down

0 comments on commit 1cacd75

Please sign in to comment.