Skip to content

Commit

Permalink
Fix for issue 7641: Wrong path to TeXstudio (#7664)
Browse files Browse the repository at this point in the history
* Fix the issue 7641

* improve the function used and remove useless output

Co-authored-by: Christoph <siedlerkiller@gmail.com>
  • Loading branch information
Gan-Cheng and Siedlerchr authored Apr 26, 2021
1 parent 21abebe commit b5c6b72
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue with opacity of disabled icon-buttons [#7195](https://github.com/JabRef/jabref/issues/7195)
- We fixed an issue where journal abbreviations in UTF-8 were not recognized [#5850](https://github.com/JabRef/jabref/issues/5850)
- We fixed an issue where the article title with curly brackets fails to download the arXiv link (pdf file). [#7633](https://github.com/JabRef/jabref/issues/7633)
- We fixed an issue with the default path of external application. [#7641](https://github.com/JabRef/jabref/issues/7641)
- We fixed an issue where urls must be embedded in a style tag when importing EndNote style Xml files. Now it can parse url with or without a style tag. [#6199](https://github.com/JabRef/jabref/issues/6199)
- We fixed an issue where the article title with colon fails to download the arXiv link (pdf file). [#7660](https://github.com/JabRef/issues/7660)

Expand Down
30 changes: 26 additions & 4 deletions src/main/java/org/jabref/gui/desktop/os/Windows.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Optional;

Expand All @@ -27,13 +28,34 @@ public void openFile(String filePath, String fileType) throws IOException {
@Override
public String detectProgramPath(String programName, String directoryName) {
String progFiles = System.getenv("ProgramFiles(x86)");
if (progFiles == null) {
progFiles = System.getenv("ProgramFiles");
String programPath;
if (progFiles != null) {
programPath = getProgramPath(programName, directoryName, progFiles);
if (programPath != null) {
return programPath;
}
}

progFiles = System.getenv("ProgramFiles");
programPath = getProgramPath(programName, directoryName, progFiles);
if (programPath != null) {
return programPath;
}

return "";
}

private String getProgramPath(String programName, String directoryName, String progFiles) {
Path programPath;
if ((directoryName != null) && !directoryName.isEmpty()) {
return Path.of(progFiles, directoryName, programName + DEFAULT_EXECUTABLE_EXTENSION).toString();
programPath = Path.of(progFiles, directoryName, programName + DEFAULT_EXECUTABLE_EXTENSION);
} else {
programPath = Path.of(progFiles, programName + DEFAULT_EXECUTABLE_EXTENSION);
}
if (Files.exists(programPath)) {
return programPath.toString();
}
return Path.of(progFiles, programName + DEFAULT_EXECUTABLE_EXTENSION).toString();
return null;
}

@Override
Expand Down

0 comments on commit b5c6b72

Please sign in to comment.