package stego.StegoCaller;

import java.io.*;
import stego.Drivers;

public class Caller_ReComposer_JAR
{

    public Caller_ReComposer_JAR(File fleExternalJAR, File fleDirectoryToReCompose)
    {
        processCommand(fleExternalJAR, fleDirectoryToReCompose);
    }

    public static boolean processCommand(File flePathToJAR, File fleAnalyzeDir)
    {
        if(flePathToJAR != null && flePathToJAR.exists() && flePathToJAR.isFile())
        {
            break MISSING_BLOCK_LABEL_27;
        }
        Drivers.jop_Error("Received File does not appear to exist", "Invalid File Specified");
        return false;
        if(fleAnalyzeDir != null && fleAnalyzeDir.exists() && fleAnalyzeDir.isDirectory())
        {
            break MISSING_BLOCK_LABEL_54;
        }
        Drivers.jop_Error("Received Directory does not appear to exist", "Invalid File Specified");
        return false;
        try
        {
            String strJAR_Name = flePathToJAR.getCanonicalPath().substring(flePathToJAR.getCanonicalPath().lastIndexOf(System.getProperty("file.separator")) + 1);
            String strCommand = (new StringBuilder("java -jar \"")).append(flePathToJAR.getCanonicalPath()).append("\"").append(" -r ").append("\"").append(fleAnalyzeDir.getCanonicalPath()).append("\"").toString();
            if(strCommand != null && !strCommand.trim().toUpperCase().startsWith("JAVA"))
            {
                Drivers.jop_Warning((new StringBuilder("WARNING: The following command: ")).append(strCommand).append("\nDoes not appear to be within expected parameters to launch a JAR file").toString(), "Unverified Command Received");
            }
            Drivers.appendTextToInteractionContent_TextPane((new StringBuilder("Executing the following command: \"")).append(strCommand).append("\"").toString(), true);
            Drivers.sop((new StringBuilder("Executing the following command: \"")).append(strCommand).append("\"").toString());
            Process p = Runtime.getRuntime().exec((new StringBuilder("cmd /c ")).append(strCommand).toString());
            BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
            BufferedWriter output = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
            for(String line = ""; (line = input.readLine()) != null;)
            {
                Drivers.sop(line);
                Drivers.appendTextToInteractionContent_TextPane(line, true);
                Drivers.sop(line);
            }

            Drivers.appendTextToInteractionContent_TextPane("\nCommand Complete", true);
            Drivers.sop("\nCommand Complete");
        }
        catch(Exception e)
        {
            Drivers.eop("processCommand", stego/StegoCaller/Caller_ReComposer_JAR.getName(), e, e.getLocalizedMessage(), true);
            return false;
        }
        return true;
    }
}
