package net.oni2.aeinstaller.backend.oni; import java.io.File; import java.io.IOException; import java.util.Vector; import net.oni2.aeinstaller.backend.AppExecution; import net.oni2.aeinstaller.backend.CaseInsensitiveFile; import net.oni2.aeinstaller.backend.DotNet; import net.oni2.aeinstaller.backend.Paths; /** * @author Christian Illy */ public class XMLTools { /** * Patch the given XML file with the given patch * * @param patch * Patchfile * @param source * File to patch * * @return XMLTools output */ public static Vector patch(File patch, File source) { Vector cmdLine = getProgramInvocation(); // xmlTools.exe patchfile -filename:PATCH -forceinfiles:TOPATCH cmdLine.add("patchfile"); cmdLine.add("-filename:" + patch.getPath()); cmdLine.add("-forceinfiles:" + source.getPath()); Vector res = null; try { res = AppExecution.executeAndWait(cmdLine); } catch (IOException e) { e.printStackTrace(); } return res; } private static Vector getProgramInvocation() { Vector res = new Vector(); if (DotNet.getRuntimeExe().length() > 0) res.add(DotNet.getRuntimeExe()); res.add(getProgramFile().getPath()); return res; } private static File getProgramFile() { File toolsPath = CaseInsensitiveFile.getCaseInsensitiveFile(Paths.getEditionBasePath(), "Tools"); return CaseInsensitiveFile.getCaseInsensitiveFile(toolsPath, "xmlTools.exe"); } }