package rhogenwizard;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class OSHelper extends OSValidator
{
	public static void killProcess(String processName) throws Exception
	{
		killProcess(processName, processName + ".exe"); 
	}
	
	public static void killProcess(String unixName, String wndName) throws Exception
	{
		List<String> cmdLine = new ArrayList<String>();
		
		if (OSValidator.OSType.WINDOWS == OSValidator.detect()) 
		{
			cmdLine.add("taskkill.exe");
			cmdLine.add("/F");
			cmdLine.add("/IM");
			cmdLine.add(wndName);
		}
		else
		{
			cmdLine.add("killall");
			cmdLine.add("-9");
			cmdLine.add(unixName);
		}
		
		SysCommandExecutor executor = new SysCommandExecutor();
		executor.runCommand(cmdLine);
	}
	
	public static void deleteFolder(String pathToRootFolder)
	{
		File rootFolder = new File(pathToRootFolder);
		
		deleteFolder(rootFolder);
	}
	
	public static void deleteFolder(File rootFolder)
	{
		if (!rootFolder.isDirectory())
		{
			rootFolder.delete();
			return;
		}
		
		File[] containFiles = rootFolder.listFiles();
		
		for (File currFile : containFiles)
		{
			deleteFolder(currFile);
		}
		
		rootFolder.delete();
	}
	
	public static void setEnvVariable(String envName, String envValue) throws Exception
	{
		List<String> cmdLine = new ArrayList<String>();
		
		if (OSValidator.OSType.WINDOWS == OSValidator.detect()) 
		{
			System.setProperty(envName, envValue);
			
//			cmdLine.add("set.exe");
//			cmdLine.add(envName + "=" + envValue);
		}
		else
		{
			cmdLine.add("export");
			cmdLine.add(envName + "=" + envValue);
		}
		
//		SysCommandExecutor executor = new SysCommandExecutor();
//		executor.runCommand(cmdLine);
	}
}

@@ -133,16 +133,150 @@
 dator%0A%7B%0A
+%09public static void killScriptProcess(String processName) throws Exception%0A%09%7B%0A%09%09killProcess(processName, processName + %22.bat%22); %0A%09%7D%0A%09%0A
 %09public 
@@ -1323,518 +1323,6 @@
 %0A%09%7D%0A
-%09%0A%09public static void setEnvVariable(String envName, String envValue) throws Exception%0A%09%7B%0A%09%09List%3CString%3E cmdLine = new ArrayList%3CString%3E();%0A%09%09%0A%09%09if (OSValidator.OSType.WINDOWS == OSValidator.detect()) %0A%09%09%7B%0A%09%09%09System.setProperty(envName, envValue);%0A%09%09%09%0A//%09%09%09cmdLine.add(%22set.exe%22);%0A//%09%09%09cmdLine.add(envName + %22=%22 + envValue);%0A%09%09%7D%0A%09%09else%0A%09%09%7B%0A%09%09%09cmdLine.add(%22export%22);%0A%09%09%09cmdLine.add(envName + %22=%22 + envValue);%0A%09%09%7D%0A%09%09%0A//%09%09SysCommandExecutor executor = new SysCommandExecutor();%0A//%09%09executor.runCommand(cmdLine);%0A%09%7D%0A
 %7D%0A

delete unused code