source: java/installer2/src/net/oni2/aeinstaller/backend/oni/XMLTools.java@ 924

Last change on this file since 924 was 924, checked in by alloc, 11 years ago

Updated to 2.17:

  • Made the download dialog a bit wider for longer mod names
  • Updated XmlTools invocation to XmlTools2
File size: 2.0 KB
RevLine 
[698]1package net.oni2.aeinstaller.backend.oni;
2
3import java.io.File;
4import java.io.IOException;
5import java.util.Vector;
6
[699]7import net.oni2.aeinstaller.backend.CaseInsensitiveFile;
[698]8import net.oni2.aeinstaller.backend.Paths;
[924]9import net.oni2.platformtools.PlatformInformation;
[720]10import net.oni2.platformtools.applicationinvoker.ApplicationInvoker;
11import net.oni2.platformtools.applicationinvoker.ApplicationInvocationResult;
12import net.oni2.platformtools.applicationinvoker.EExeType;
13import net.oni2.platformtools.applicationinvoker.ERuntimeNotInstalledException;
[698]14
15/**
16 * @author Christian Illy
17 */
18public 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}
Note: See TracBrowser for help on using the repository browser.