Changeset 62 for java


Ignore:
Timestamp:
02/08/10 22:44:42 (14 years ago)
Author:
mszubert
Message:

Checking OS before executing frams command.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • java/ecj/framsticks/FramsticksUtils.java

    r61 r62  
    9191                try {
    9292                        File f = new File(directoryPath);
    93                         Process p = Runtime.getRuntime().exec(
    94                                         new String[] { "cmd.exe", "/C", directoryPath + command }, null, f);
     93                       
     94                        String[] cmd;
     95                        String os = System.getProperty("os.name");
     96                        if(os.contains("Linux"))
     97                        {
     98                                cmd = new String[] { "/bin/bash", "-c", directoryPath + command };
     99                        }
     100                        else if(os.contains("Windows"))
     101                        {
     102                                cmd = new String[] { "cmd.exe", "/C", directoryPath + command };
     103                        }
     104                        else
     105                        {
     106                                throw new Exception("Not supported OS");
     107                        }
     108                       
     109                        Process p = Runtime.getRuntime().exec(cmd, null, f);
     110                       
    95111                        BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
    96112                        result = readInput(input);
     
    105121                return result;
    106122        }
    107 
     123       
    108124        private void saveToFile(String filePath, String contents) {
    109125                try {
Note: See TracChangeset for help on using the changeset viewer.