[698] | 1 | package net.oni2.aeinstaller.backend.oni;
|
---|
| 2 |
|
---|
| 3 | import java.io.File;
|
---|
| 4 | import java.io.IOException;
|
---|
| 5 | import java.util.Vector;
|
---|
| 6 |
|
---|
[699] | 7 | import net.oni2.aeinstaller.backend.CaseInsensitiveFile;
|
---|
[698] | 8 | import net.oni2.aeinstaller.backend.Paths;
|
---|
[924] | 9 | import net.oni2.platformtools.PlatformInformation;
|
---|
[720] | 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;
|
---|
[698] | 14 |
|
---|
| 15 | /**
|
---|
| 16 | * @author Christian Illy
|
---|
| 17 | */
|
---|
| 18 | public class XMLTools {
|
---|
| 19 |
|
---|
| 20 | /**
|
---|
[924] | 21 | * Patch the XML files in the path with the patches in the other path
|
---|
[698] | 22 | *
|
---|
[924] | 23 | * @param folderWithPatches
|
---|
| 24 | * Path containing patches to apply
|
---|
| 25 | * @param folderWithXml
|
---|
| 26 | * Path containing XML files to patch
|
---|
[698] | 27 | *
|
---|
| 28 | * @return XMLTools output
|
---|
| 29 | */
|
---|
[924] | 30 | public static ApplicationInvocationResult patch(File folderWithPatches,
|
---|
| 31 | File folderWithXml) {
|
---|
[720] | 32 | Vector<String> params = new Vector<String>();
|
---|
[924] | 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());
|
---|
[720] | 37 | ApplicationInvocationResult res = null;
|
---|
[698] | 38 | try {
|
---|
[924] | 39 | res = ApplicationInvoker.executeAndWait(EExeType.OSBINARY, null,
|
---|
[767] | 40 | getProgramFile(), params, false);
|
---|
[698] | 41 | } catch (IOException e) {
|
---|
| 42 | e.printStackTrace();
|
---|
[720] | 43 | } catch (ERuntimeNotInstalledException e) {
|
---|
| 44 | e.printStackTrace();
|
---|
[698] | 45 | }
|
---|
| 46 | return res;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | private static File getProgramFile() {
|
---|
[720] | 50 | File toolsPath = CaseInsensitiveFile.getCaseInsensitiveFile(
|
---|
| 51 | Paths.getEditionBasePath(), "Tools");
|
---|
[924] | 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;
|
---|
[698] | 65 | }
|
---|
| 66 | }
|
---|