Changeset 6795


Ignore:
Timestamp:
2004-02-12T17:05:28+13:00 (20 years ago)
Author:
kjdon
Message:

made the getCommand method return String[] instead of String in case there are spaces in the filename

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/Gatherer.java

    r6770 r6795  
    449449     */
    450450    public void spawnApplication(File file) {
    451     String command = assoc_man.getCommand(file);
    452     if(command != null) {
    453         ExternalApplication app = new ExternalApplication(command);
     451    String [] commands = assoc_man.getCommand(file);
     452    if(commands != null) {
     453        ExternalApplication app = new ExternalApplication(commands);
    454454        apps.add(app);
    455455        app.start();
  • trunk/gli/src/org/greenstone/gatherer/file/FileAssociationManager.java

    r6786 r6795  
    4545    static final private String ESCAPE = "\\\\"; // '\'
    4646    static final private String ESCAPED_ESCAPE = "\\\\\\\\"; // '\\'
     47    static final private String SPACE = " ";
     48    static final private String ESCAPED_SPACE = "\\\\ ";
    4749    private Element associations_element;
    4850    private File data_file;   
     
    165167    }
    166168   
    167     public String getCommand(File file) {
     169    public String [] getCommand(File file) {
    168170    String command = null;
     171    String [] commands = null;
    169172    if(file.isFile()) {
    170173        // Determine extension
     
    220223        }
    221224        if(command != null) {
     225        // Make the command into a string [] just in case the filename has spaces in it
     226        commands = command.split(" ");
     227       
    222228        // We have to fix filename under windows to escape the backslashes.
    223229        filename = filename.replaceAll(ESCAPE, ESCAPED_ESCAPE);
    224230        // Replace %1 with the appropriate filename
    225         command = command.replaceAll(FILENAME_ARG, filename);
     231        for(int i=0; i<commands.length; i++) {
     232            if (commands[i].equals(FILENAME_ARG)) {
     233            commands[i] = filename;
     234            }
     235        }
     236        //command = command.replaceAll(FILENAME_ARG, filename);
    226237        }
    227238       
     
    230241        filename = null;
    231242    }
    232     return command;
     243    return commands;
    233244    }
    234245
Note: See TracChangeset for help on using the changeset viewer.