1 | package net.oni2.aeinstaller.backend.oni;
|
---|
2 |
|
---|
3 | import java.io.File;
|
---|
4 | import java.io.IOException;
|
---|
5 | import java.util.Vector;
|
---|
6 |
|
---|
7 | import net.oni2.aeinstaller.backend.CaseInsensitiveFile;
|
---|
8 | import net.oni2.aeinstaller.backend.DotNet;
|
---|
9 | import net.oni2.aeinstaller.backend.Paths;
|
---|
10 | import net.oni2.applicationinvoker.AppExecution;
|
---|
11 | import net.oni2.applicationinvoker.AppExecutionResult;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * @author Christian Illy
|
---|
15 | */
|
---|
16 | public class XMLTools {
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Patch the given XML file with the given patch
|
---|
20 | *
|
---|
21 | * @param patch
|
---|
22 | * Patchfile
|
---|
23 | * @param source
|
---|
24 | * File to patch
|
---|
25 | *
|
---|
26 | * @return XMLTools output
|
---|
27 | */
|
---|
28 | public static AppExecutionResult patch(File patch, File source) {
|
---|
29 | Vector<String> cmdLine = getProgramInvocation();
|
---|
30 | // xmlTools.exe patchfile -filename:PATCH -forceinfiles:TOPATCH
|
---|
31 | cmdLine.add("patchfile");
|
---|
32 | cmdLine.add("-filename:" + patch.getPath());
|
---|
33 | cmdLine.add("-forceinfiles:" + source.getPath());
|
---|
34 | AppExecutionResult res = null;
|
---|
35 | try {
|
---|
36 | res = AppExecution.executeAndWait(cmdLine);
|
---|
37 | } catch (IOException e) {
|
---|
38 | e.printStackTrace();
|
---|
39 | }
|
---|
40 | return res;
|
---|
41 | }
|
---|
42 |
|
---|
43 | private static Vector<String> getProgramInvocation() {
|
---|
44 | Vector<String> res = new Vector<String>();
|
---|
45 | if (DotNet.getRuntimeExe().length() > 0)
|
---|
46 | res.add(DotNet.getRuntimeExe());
|
---|
47 | res.add(getProgramFile().getPath());
|
---|
48 | return res;
|
---|
49 | }
|
---|
50 |
|
---|
51 | private static File getProgramFile() {
|
---|
52 | File toolsPath = CaseInsensitiveFile.getCaseInsensitiveFile(Paths.getEditionBasePath(), "Tools");
|
---|
53 | return CaseInsensitiveFile.getCaseInsensitiveFile(toolsPath, "xmlTools.exe");
|
---|
54 | }
|
---|
55 | }
|
---|