Changeset 9657


Ignore:
Timestamp:
2005-04-13T10:21:50+12:00 (19 years ago)
Author:
davidb
Message:

Files with spaces in failed to launch properly. The relevant section
has been reworked to avoid this pitfall. The split on spaces now happens
*before* %1 is substituted with its real filename.

File:
1 edited

Legend:

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

    r8240 r9657  
    2828
    2929import java.io.*;
     30import java.util.regex.*;
    3031import javax.swing.table.*;
    3132import org.greenstone.gatherer.Configuration;
     
    212213        }
    213214        if(command != null) {
     215
     216        // Make the command into a string []       
     217        commands = command.split(" ");
     218
     219        // Now substitute any occurrences of %1 with its filename
     220        // Note this is done after the split on spaces to avoid
     221        // any conflict with filenames with spaces in them.
     222
    214223        // We have to fix filename under windows to escape the backslashes
    215224        filename = filename.replaceAll(ESCAPE, ESCAPED_ESCAPE);
    216         // Replace %1 with the appropriate filename
    217         command = command.replaceAll(FILENAME_ARG, filename);
    218 
    219         // Make the command into a string [] in case the filename has spaces in it
    220         commands = command.split(" ");
     225
     226        for (int i=0; i<commands.length; i++) {
     227            // Replace %1 with the appropriate filename
     228            commands[i] = commands[i].replaceAll(FILENAME_ARG, filename);
     229        }
     230
    221231        }
    222232       
Note: See TracChangeset for help on using the changeset viewer.