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.Paths;
|
---|
9 | import net.oni2.platformtools.PlatformInformation;
|
---|
10 | import net.oni2.platformtools.applicationinvoker.ApplicationInvoker;
|
---|
11 | import net.oni2.platformtools.applicationinvoker.ApplicationInvocationResult;
|
---|
12 | import net.oni2.platformtools.applicationinvoker.EExeType;
|
---|
13 | import net.oni2.platformtools.applicationinvoker.ERuntimeNotInstalledException;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * @author Christian Illy
|
---|
17 | */
|
---|
18 | public class XMLTools {
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * Patch the XML files in the path with the patches in the other path
|
---|
22 | *
|
---|
23 | * @param folderWithPatches
|
---|
24 | * Path containing patches to apply
|
---|
25 | * @param folderWithXml
|
---|
26 | * Path containing XML files to patch
|
---|
27 | *
|
---|
28 | * @return XMLTools output
|
---|
29 | */
|
---|
30 | public static ApplicationInvocationResult patch(File folderWithPatches,
|
---|
31 | File folderWithXml) {
|
---|
32 | Vector<String> params = new Vector<String>();
|
---|
33 | // xmlTools.exe --patch-files PATCH --force-target-files TOPATCH
|
---|
34 | params.add("--patch-files "
|
---|
35 | + new File(folderWithPatches, "*.oni-patch").getPath());
|
---|
36 | params.add("--use-patch-filename " + folderWithXml.getPath());
|
---|
37 | ApplicationInvocationResult res = null;
|
---|
38 | try {
|
---|
39 | res = ApplicationInvoker.executeAndWait(EExeType.OSBINARY, null,
|
---|
40 | getProgramFile(), params, false);
|
---|
41 | } catch (IOException e) {
|
---|
42 | e.printStackTrace();
|
---|
43 | } catch (ERuntimeNotInstalledException e) {
|
---|
44 | e.printStackTrace();
|
---|
45 | }
|
---|
46 | return res;
|
---|
47 | }
|
---|
48 |
|
---|
49 | private static File getProgramFile() {
|
---|
50 | File toolsPath = CaseInsensitiveFile.getCaseInsensitiveFile(
|
---|
51 | Paths.getEditionBasePath(), "Tools");
|
---|
52 | File xmlToolsPath = CaseInsensitiveFile.getCaseInsensitiveFile(
|
---|
53 | toolsPath, "XmlTools");
|
---|
54 | switch (PlatformInformation.getPlatform()) {
|
---|
55 | case WIN:
|
---|
56 | return CaseInsensitiveFile.getCaseInsensitiveFile(xmlToolsPath,
|
---|
57 | "XmlTools.exe");
|
---|
58 | case LINUX:
|
---|
59 | case MACOS:
|
---|
60 | return CaseInsensitiveFile.getCaseInsensitiveFile(xmlToolsPath,
|
---|
61 | "XmlTools");
|
---|
62 | default:
|
---|
63 | }
|
---|
64 | return null;
|
---|
65 | }
|
---|
66 | }
|
---|