Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

LinuxDefaultPaths: return either absolute tool's path if executable f…

…ound in project.binaries.dir or short to search in system-wide PATH.
  • Loading branch information...
commit ca52785597465072adaa00c42907655c5cbe50a3 1 parent 9d16bdb
@Happy-Neko Happy-Neko authored
Showing with 31 additions and 10 deletions.
  1. +31 −10 src/main/java/net/pms/configuration/LinuxDefaultPaths.java
View
41 src/main/java/net/pms/configuration/LinuxDefaultPaths.java
@@ -2,50 +2,54 @@
import net.pms.util.PropertiesUtil;
+import java.io.File;
+
class LinuxDefaultPaths implements ProgramPaths {
+ private final String BINARIES_SEARCH_PATH = getBinariesSearchPath();
+
@Override
public String getEac3toPath() {
- return "eac3to";
+ return getBinaryPath("eac3to");
}
@Override
public String getFfmpegPath() {
- return "ffmpeg";
+ return getBinaryPath("ffmpeg");
}
@Override
public String getFlacPath() {
- return "flac";
+ return getBinaryPath("flac");
}
@Override
public String getMencoderPath() {
- return "mencoder";
+ return getBinaryPath("mencoder");
}
@Override
public String getMplayerPath() {
- return "mplayer";
+ return getBinaryPath("mplayer");
}
@Override
public String getTsmuxerPath() {
- return getBinariesPath() + "linux/tsMuxeR";
+ return getBinaryPath("tsMuxeR");
}
@Override
public String getVlcPath() {
- return "vlc";
+ return getBinaryPath("vlc");
}
@Override
public String getDCRaw() {
- return "dcraw";
+ return getBinaryPath("dcraw");
}
@Override
public String getIMConvertPath() {
- return "convert";
+ return getBinaryPath("convert");
}
/**
@@ -55,7 +59,7 @@ public String getIMConvertPath() {
*
* @return The path for binaries.
*/
- private String getBinariesPath() {
+ private String getBinariesSearchPath() {
String path = PropertiesUtil.getProjectProperties().get("project.binaries.dir");
if (path != null && !"".equals(path)) {
@@ -68,4 +72,21 @@ private String getBinariesPath() {
return "";
}
}
+
+ /**
+ * Returns the path to requested binary tool.
+ * Either absolute if executable found in project.binaries.dir or
+ * short to search in system-wide PATH.
+ *
+ * @param tool The name of binary tool
+ * @return Path to binary
+ */
+ private String getBinaryPath(String tool) {
+ File f = new File(BINARIES_SEARCH_PATH + tool);
+ if (f.canExecute()) {
+ return BINARIES_SEARCH_PATH + tool;
+ } else {
+ return tool;
+ }
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.