3 import java.io.IOException;
7 * Class to manage interfaces to external tools, like exiftool
9 public abstract class ExternalTools
11 /** Constant for Exiftool */
12 public static final int TOOL_EXIFTOOL = 0;
13 /** Constant for Gpsbabel */
14 public static final int TOOL_GPSBABEL = 1;
15 /** Constant for Gnuplot */
16 public static final int TOOL_GNUPLOT = 2;
17 /** Config keys in order that the tools are defined above */
18 private static final String[] CONFIG_KEYS = {Config.KEY_EXIFTOOL_PATH, Config.KEY_GPSBABEL_PATH, Config.KEY_GNUPLOT_PATH};
19 /** Verification flags for the tools in the order defined above */
20 private static final String[] VERIFY_FLAGS = {"-v", "-V", "-V"};
24 * Check if the selected tool is installed
25 * @param inToolNum number of tool, from constants
26 * @return true if selected tool is installed
28 public static boolean isToolInstalled(int inToolNum)
34 String toolPath = Config.getConfigString(CONFIG_KEYS[inToolNum]);
35 if (toolPath != null && toolPath.length() > 0) {
36 return check(toolPath + " " + VERIFY_FLAGS[inToolNum]);
44 * Check if the selected tool is installed using the given path
45 * @param inToolNum number of tool, from constants
46 * @param inPath selected path to use instead of configured one
47 * @return true if selected tool is installed
49 public static boolean isToolInstalled(int inToolNum, String inPath)
51 if (inPath == null || inPath.equals("")) {return false;}
56 return check(inPath + " " + VERIFY_FLAGS[inToolNum]);
63 * Attempt to call the specified command
64 * @return true if found, false otherwise
66 private static boolean check(String inCommand)
68 // System.out.println("Checking tool '" + inCommand + "'");
71 Runtime.getRuntime().exec(inCommand);
74 catch (IOException ioe)
76 // exception thrown, command not found