Changeset 31637


Ignore:
Timestamp:
2017-04-27T20:46:05+12:00 (7 years ago)
Author:
ak19
Message:

FileAssociationManager no longer uses ExternalProgram to run the which command, uses SafeProcess.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/file/FileAssociationManager.java

    r24709 r31637  
    3535import org.greenstone.gatherer.gui.FileAssociationDialog;
    3636import org.greenstone.gatherer.gui.PreviewCommandDialog;
    37 import org.greenstone.gatherer.util.ExternalProgram;
     37import org.greenstone.gatherer.util.SafeProcess;
    3838import org.greenstone.gatherer.util.StaticStrings;
    3939import org.greenstone.gatherer.util.Utility;
     
    115115    } else {
    116116        // we try to look for a browser
    117         String [] browsers = new String [] {"mozilla", "netscape"};
     117        String [] browsers = new String [] {"mozilla", "netscape", "firefox"};
    118118        for (int i=0; i<browsers.length; i++) {
    119119        if (isAvailable(browsers[i])) {
     
    354354    protected boolean isAvailable(String program) {
    355355    try {
    356         ExternalProgram e = new ExternalProgram("which", program);
    357         e.exitProgram();
    358         String out = e.getLineOfProgramOutput();
    359         if (out == null) {
     356        // `which bla` does nothing, prompt is returned
     357        // `which grep` returns a line of output with the path to grep
     358        SafeProcess prcs = new SafeProcess("which " + program);
     359        prcs.runProcess();
     360        String output = prcs.getStdOutput();
     361        if(output.equals("")) {
    360362        return false;
    361363        }
     364        //System.err.println("*** 'which " + program + "' returned: " + output);
    362365        return true;
    363366    } catch (Exception exc) {
Note: See TracChangeset for help on using the changeset viewer.