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
Line 
1package net.oni2.aeinstaller.backend.oni;
2
3import java.io.File;
4import java.io.IOException;
5import java.util.Vector;
6
7import net.oni2.aeinstaller.backend.CaseInsensitiveFile;
8import net.oni2.aeinstaller.backend.Paths;
9import net.oni2.platformtools.PlatformInformation;
10import net.oni2.platformtools.applicationinvoker.ApplicationInvoker;
11import net.oni2.platformtools.applicationinvoker.ApplicationInvocationResult;
12import net.oni2.platformtools.applicationinvoker.EExeType;
13import net.oni2.platformtools.applicationinvoker.ERuntimeNotInstalledException;
14
15/**
16 * @author Christian Illy
17 */
18public 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}
Note: See TracBrowser for help on using the repository browser.