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