source: AE/installer2/src/net/oni2/aeinstaller/backend/oni/OniSplit.java@ 695

Last change on this file since 695 was 672, checked in by alloc, 12 years ago

AEI2 0.99q:

  • Updates dialog: Updating the to-download-size on (un)checking updates to download
  • Updates dialog: Show download size of individual updates
  • Tool execution: Support for .NET tools (Mod_Info.cfg added ExeType flag)
  • Depot backend: Ignore mod nodes with an empty package number field
File size: 4.1 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.DotNet;
8import net.oni2.aeinstaller.backend.Paths;
9import net.oni2.aeinstaller.backend.AppExecution;
10import net.oni2.aeinstaller.backend.Settings;
11import net.oni2.aeinstaller.backend.Settings.Platform;
12
13/**
14 * @author Christian Illy
15 */
16public class OniSplit {
17
18 /**
19 * @return Is Onisplit installed?
20 */
21 public static boolean isOniSplitInstalled() {
22 return getProgramFile().exists();
23 }
24
25 /**
26 * Export given dat-file to target folder
27 *
28 * @param targetFolder
29 * Target folder
30 * @param input
31 * Dat file
32 * @return OniSplit output
33 */
34 public static Vector<String> export(File targetFolder, File input) {
35 if (!targetFolder.exists())
36 targetFolder.mkdir();
37
38 Vector<String> cmdLine = getProgramInvocation();
39 cmdLine.add("-export");
40 cmdLine.add(targetFolder.getPath());
41 cmdLine.add(input.getPath());
42 Vector<String> res = null;
43 try {
44 res = AppExecution.executeAndWait(cmdLine);
45 } catch (IOException e) {
46 e.printStackTrace();
47 }
48 return res;
49 }
50
51 /**
52 * Import given folder to a .dat-file
53 *
54 * @param sourceFolders
55 * Folders containing .oni-files
56 * @param targetFile
57 * Target .dat-file
58 * @return OniSplit output
59 */
60 public static Vector<String> importLevel(Vector<File> sourceFolders,
61 File targetFile) {
62 Vector<String> cmdLine = getProgramInvocation();
63 cmdLine.add(getImportParam());
64 for (File f : sourceFolders)
65 cmdLine.add(f.getPath());
66 cmdLine.add(targetFile.getPath());
67 Vector<String> res = null;
68 try {
69 res = AppExecution.executeAndWait(cmdLine);
70 } catch (IOException e) {
71 e.printStackTrace();
72 }
73 return res;
74 }
75
76 /**
77 * Pack a level to a .dat-file. More powerful variant which allows
78 * specifying single .oni/.dat files
79 *
80 * @param sourceFoldersFiles
81 * Folders (for recursive .oni import) or files (.dat and single
82 * .oni) to import
83 * @param targetFile
84 * Target .dat-file
85 * @return OniSplit output
86 */
87 public static Vector<String> packLevel(Vector<File> sourceFoldersFiles,
88 File targetFile) {
89 Vector<String> cmdLine = getProgramInvocation();
90 cmdLine.add(getPackParam());
91 cmdLine.add(getPackTypeParam());
92 cmdLine.add("-out");
93 cmdLine.add(targetFile.getPath());
94 for (File f : sourceFoldersFiles)
95 cmdLine.add(f.getPath());
96 Vector<String> res = null;
97 try {
98 res = AppExecution.executeAndWait(cmdLine);
99 } catch (IOException e) {
100 e.printStackTrace();
101 }
102 return res;
103 }
104
105 /**
106 * Move files from one location to another using OniSplit so relations are
107 * handled
108 *
109 * @param targetFolder
110 * Target folder for files
111 * @param input
112 * Files to move, can contain wildcards
113 * @param moveParameter
114 * e.g. overwrite, delete
115 * @return OniSplit output
116 */
117 public static Vector<String> move(File targetFolder, String input,
118 String moveParameter) {
119 if (!targetFolder.exists())
120 targetFolder.mkdir();
121
122 Vector<String> cmdLine = getProgramInvocation();
123 cmdLine.add("-move"
124 + (moveParameter != null ? ":" + moveParameter : ""));
125 cmdLine.add(targetFolder.getPath());
126 cmdLine.add(input);
127 Vector<String> res = null;
128 try {
129 res = AppExecution.executeAndWait(cmdLine);
130 } catch (IOException e) {
131 e.printStackTrace();
132 }
133 return res;
134 }
135
136 private static String getImportParam() {
137 if (Settings.getPlatform() == Platform.MACOS)
138 return "-import:sep";
139 else
140 return "-import:nosep";
141 }
142
143 private static String getPackParam() {
144 return "pack";
145 }
146
147 private static String getPackTypeParam() {
148 if (Settings.getPlatform() == Platform.MACOS)
149 return "-type:macintel";
150 else
151 return "-type:pc";
152 }
153
154 private static Vector<String> getProgramInvocation() {
155 Vector<String> res = new Vector<String>();
156 if (DotNet.getRuntimeExe().length() > 0)
157 res.add(DotNet.getRuntimeExe());
158 res.add(getProgramFile().getPath());
159 return res;
160 }
161
162 private static File getProgramFile() {
163 return new File(new File(Paths.getEditionBasePath(), "Tools"),
164 "Onisplit.exe");
165 }
166}
Note: See TracBrowser for help on using the repository browser.