package info.ajaxplorer.client.util;

import java.io.File;
import java.io.IOException;

public class RdiffProcessor {

	private String rdiffPath = "G:\\PROGRAMS\\rdiff\\rdiff.exe";
	
	public static boolean rdiffEnabled(){
		return true;
	}
	
	public RdiffProcessor(){
		
	}
	
	public void signature(File source, File signature){
		try {
			String[] command = {rdiffPath, "signature", "\""+source.getCanonicalPath()+"\"", "\""+signature.getCanonicalPath()+"\""};
			Process p = Runtime.getRuntime().exec(command);
			int exitValue = p.waitFor();
			//System.out.println("Process exitValue: " + exitValue);
		} catch (IOException e) {
			e.printStackTrace();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	public void delta(File signature, File source, File delta){
		try {
			String[] cmd = {
					rdiffPath, 
					"delta", 
					"\""+signature.getCanonicalPath()+"\"",
					"\""+source.getCanonicalPath()+"\"",
					"\""+delta.getCanonicalPath()+"\""
				};
			Process p = Runtime.getRuntime().exec(cmd);
			int exitValue = p.waitFor();
			//System.out.println("Process exitValue: " + exitValue);
		} catch (IOException e) {
			e.printStackTrace();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	public void patch(File source, File delta, File target){
		try {
			String[] cmd = {
					rdiffPath, 
					"patch", 
					"\""+source.getCanonicalPath()+"\"",
					"\""+delta.getCanonicalPath()+"\"",
					"\""+target.getCanonicalPath()+"\""
				};
			Process p = Runtime.getRuntime().exec(cmd);
			int exitValue = p.waitFor();
			//System.out.println("Process exitValue: " + exitValue);
		} catch (IOException e) {
			e.printStackTrace();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
}

package info.ajaxplorer.client.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;

public class RdiffProcessor {

	private String rdiffPath;
	private boolean testEnabled = false;
	
	public boolean rdiffEnabled(){
		return testEnabled;
	}
	
	public RdiffProcessor(String path){
		rdiffPath = path;
		try{
			testEnabled = testCommand();
		}catch(Exception e){
			testEnabled = false;
		}
	}
	
	protected boolean testCommand() throws IOException, InterruptedException{
		
		String line;
		StringBuilder sb = new StringBuilder();
		Process p = Runtime.getRuntime().exec(rdiffPath);
		BufferedReader bri = new BufferedReader(new InputStreamReader(p.getErrorStream()));
		while ((line = bri.readLine()) != null) {
			sb.append(line);
		}
		bri.close();
		p.waitFor();
		String s = sb.toString();
		return (s.indexOf("signature") > -1 && s.indexOf("patch") > -1 && s.indexOf("delta") > -1);
	}
	
	
	public void signature(File source, File signature){
		try {
			String[] command = {rdiffPath, "signature", "\""+source.getCanonicalPath()+"\"", "\""+signature.getCanonicalPath()+"\""};
			Process p = Runtime.getRuntime().exec(command);
			int exitValue = p.waitFor();
			//System.out.println("Process exitValue: " + exitValue);
		} catch (IOException e) {
			e.printStackTrace();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	public void delta(File signature, File source, File delta){
		try {
			String[] cmd = {
					rdiffPath, 
					"delta", 
					"\""+signature.getCanonicalPath()+"\"",
					"\""+source.getCanonicalPath()+"\"",
					"\""+delta.getCanonicalPath()+"\""
				};
			Process p = Runtime.getRuntime().exec(cmd);
			int exitValue = p.waitFor();
			//System.out.println("Process exitValue: " + exitValue);
		} catch (IOException e) {
			e.printStackTrace();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	public void patch(File source, File delta, File target){
		try {
			String[] cmd = {
					rdiffPath, 
					"patch", 
					"\""+source.getCanonicalPath()+"\"",
					"\""+delta.getCanonicalPath()+"\"",
					"\""+target.getCanonicalPath()+"\""
				};
			Process p = Runtime.getRuntime().exec(cmd);
			int exitValue = p.waitFor();
			//System.out.println("Process exitValue: " + exitValue);
		} catch (IOException e) {
			e.printStackTrace();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
}

Change rdiff proc initialisation