ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/AE/installer2/src/net/oni2/aeinstaller/backend/oni/Installer.java
Revision: 653
Committed: Fri Jan 25 14:57:36 2013 UTC (12 years, 10 months ago) by alloc
Content type: text/x-java
File size: 22291 byte(s)
Log Message:
AEI2 0.99g:
- Fixed MacOS launch
- Added version information to installation.log

File Contents

# Content
1 package net.oni2.aeinstaller.backend.oni;
2
3 import java.io.File;
4 import java.io.FileFilter;
5 import java.io.FileInputStream;
6 import java.io.FileNotFoundException;
7 import java.io.FileOutputStream;
8 import java.io.FilenameFilter;
9 import java.io.IOException;
10 import java.io.InputStream;
11 import java.io.PrintWriter;
12 import java.text.SimpleDateFormat;
13 import java.util.Date;
14 import java.util.HashMap;
15 import java.util.HashSet;
16 import java.util.List;
17 import java.util.Scanner;
18 import java.util.TreeMap;
19 import java.util.TreeSet;
20 import java.util.Vector;
21
22 import net.oni2.aeinstaller.AEInstaller2;
23 import net.oni2.aeinstaller.backend.Paths;
24 import net.oni2.aeinstaller.backend.Settings;
25 import net.oni2.aeinstaller.backend.Settings.Platform;
26 import net.oni2.aeinstaller.backend.packages.EBSLInstallType;
27 import net.oni2.aeinstaller.backend.packages.Package;
28 import net.oni2.aeinstaller.backend.packages.PackageManager;
29
30 import org.apache.commons.io.FileUtils;
31
32 import com.thoughtworks.xstream.XStream;
33 import com.thoughtworks.xstream.io.xml.StaxDriver;
34
35 /**
36 * @author Christian Illy
37 */
38 public class Installer {
39 private static FileFilter dirFileFilter = new FileFilter() {
40 @Override
41 public boolean accept(File pathname) {
42 return pathname.isDirectory();
43 }
44 };
45
46 /**
47 * @return Is Edition Core initialized
48 */
49 public static boolean isEditionInitialized() {
50 return Paths.getVanillaOnisPath().exists();
51 }
52
53 private static void createEmptyPath(File path) throws IOException {
54 if (path.exists())
55 FileUtils.deleteDirectory(path);
56 path.mkdirs();
57 }
58
59 /**
60 * @return list of currently installed mods
61 */
62 public static Vector<Integer> getInstalledMods() {
63 File installCfg = new File(Paths.getEditionGDF(), "installed_mods.xml");
64 return PackageManager.getInstance().loadModSelection(installCfg);
65 }
66
67 /**
68 * @return Currently installed tools
69 */
70 @SuppressWarnings("unchecked")
71 public static TreeSet<Integer> getInstalledTools() {
72 File installCfg = new File(Paths.getInstallerPath(),
73 "installed_tools.xml");
74 TreeSet<Integer> res = new TreeSet<Integer>();
75 try {
76 if (installCfg.exists()) {
77 FileInputStream fis = new FileInputStream(installCfg);
78 XStream xs = new XStream(new StaxDriver());
79 Object obj = xs.fromXML(fis);
80 if (obj instanceof TreeSet<?>)
81 res = (TreeSet<Integer>) obj;
82 fis.close();
83 }
84 } catch (FileNotFoundException e) {
85 e.printStackTrace();
86 } catch (IOException e) {
87 e.printStackTrace();
88 }
89 return res;
90 }
91
92 private static void writeInstalledTools(TreeSet<Integer> tools) {
93 File installCfg = new File(Paths.getInstallerPath(),
94 "installed_tools.xml");
95 try {
96 FileOutputStream fos = new FileOutputStream(installCfg);
97 XStream xs = new XStream(new StaxDriver());
98 xs.toXML(tools, fos);
99 fos.close();
100 } catch (FileNotFoundException e) {
101 e.printStackTrace();
102 } catch (IOException e) {
103 e.printStackTrace();
104 }
105 }
106
107 /**
108 * @param tools
109 * Tools to install
110 */
111 public static void installTools(TreeSet<Package> tools) {
112 TreeSet<Integer> installed = getInstalledTools();
113 for (Package m : tools) {
114 File plain = new File(m.getLocalPath(), "plain");
115 if (plain.exists()) {
116 if (m.hasSeparatePlatformDirs()) {
117 File plainCommon = new File(plain, "common");
118 File plainMac = new File(plain, "mac_only");
119 File plainWin = new File(plain, "win_only");
120 if (plainCommon.exists())
121 copyToolsFiles(plainCommon);
122 if (Settings.getPlatform() == Platform.MACOS
123 && plainMac.exists())
124 copyToolsFiles(plainMac);
125 else if (plainWin.exists())
126 copyToolsFiles(plainWin);
127 } else {
128 copyToolsFiles(plain);
129 }
130 }
131 installed.add(m.getPackageNumber());
132 }
133 writeInstalledTools(installed);
134 }
135
136 /**
137 * @param tools
138 * Tools to uninstall
139 */
140 public static void uninstallTools(TreeSet<Package> tools) {
141 TreeSet<Integer> installed = getInstalledTools();
142 for (Package m : tools) {
143 if (installed.contains(m.getPackageNumber())) {
144 File plain = new File(m.getLocalPath(), "plain");
145 if (plain.exists()) {
146 if (m.hasSeparatePlatformDirs()) {
147 File plainCommon = new File(plain, "common");
148 File plainMac = new File(plain, "mac_only");
149 File plainWin = new File(plain, "win_only");
150 if (plainCommon.exists())
151 removeToolsFiles(plainCommon,
152 Paths.getEditionBasePath());
153 if (Settings.getPlatform() == Platform.MACOS
154 && plainMac.exists())
155 removeToolsFiles(plainMac,
156 Paths.getEditionBasePath());
157 else if (plainWin.exists())
158 removeToolsFiles(plainWin,
159 Paths.getEditionBasePath());
160 } else {
161 removeToolsFiles(plain, Paths.getEditionBasePath());
162 }
163 }
164 }
165 installed.remove(m.getPackageNumber());
166 }
167 writeInstalledTools(installed);
168 }
169
170 private static void copyToolsFiles(File srcFolder) {
171 for (File f : srcFolder.listFiles()) {
172 try {
173 if (f.isDirectory())
174 FileUtils.copyDirectoryToDirectory(f,
175 Paths.getEditionBasePath());
176 else
177 FileUtils
178 .copyFileToDirectory(f, Paths.getEditionBasePath());
179 } catch (IOException e) {
180 e.printStackTrace();
181 }
182 }
183 }
184
185 private static void removeToolsFiles(File srcFolder, File target) {
186 for (File f : srcFolder.listFiles()) {
187 if (f.isDirectory())
188 removeToolsFiles(f, new File(target, f.getName()));
189 else {
190 File targetFile = new File(target, f.getName());
191 if (targetFile.exists())
192 targetFile.delete();
193 }
194 }
195 if (target.list().length == 0)
196 target.delete();
197 }
198
199 /**
200 * Install the given set of mods
201 *
202 * @param mods
203 * Mods to install
204 * @param listener
205 * Listener for install progress updates
206 */
207 public static void install(TreeSet<Package> mods,
208 InstallProgressListener listener) {
209 try {
210 createEmptyPath(Paths.getEditionGDF());
211 } catch (IOException e) {
212 e.printStackTrace();
213 }
214
215 File logFile = new File(Paths.getInstallerPath(), "Installation.log");
216 PrintWriter log = null;
217 try {
218 log = new PrintWriter(logFile);
219 } catch (FileNotFoundException e) {
220 e.printStackTrace();
221 }
222 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
223 Date start = new Date();
224 log.println("Installation of mods started at " + sdf.format(start));
225
226 log.println();
227 log.println("Installed tools:");
228 for (Package t : PackageManager.getInstance().getInstalledTools()) {
229 log.println(String.format(" - %s (%s)", t.getName(), t.getVersion()));
230 }
231 log.println("Installing mods:");
232 for (Package m : mods) {
233 log.println(String.format(" - %s (%s)", m.getName(), m.getVersion()));
234 }
235 log.println();
236
237 File installCfg = new File(Paths.getEditionGDF(), "installed_mods.xml");
238 PackageManager.getInstance().saveModSelection(installCfg, mods);
239
240 TreeSet<Integer> unlockLevels = new TreeSet<Integer>();
241
242 Vector<File> foldersOni = new Vector<File>();
243 foldersOni.add(Paths.getVanillaOnisPath());
244
245 for (Package m : mods) {
246 for (int lev : m.getUnlockLevels())
247 unlockLevels.add(lev);
248
249 File oni = new File(m.getLocalPath(), "oni");
250 if (oni.exists()) {
251 if (m.hasSeparatePlatformDirs()) {
252 File oniCommon = new File(oni, "common");
253 File oniMac = new File(oni, "mac_only");
254 File oniWin = new File(oni, "win_only");
255 if (oniCommon.exists())
256 foldersOni.add(oniCommon);
257 if (Settings.getPlatform() == Platform.MACOS
258 && oniMac.exists())
259 foldersOni.add(oniMac);
260 else if (oniWin.exists())
261 foldersOni.add(oniWin);
262 } else {
263 foldersOni.add(oni);
264 }
265 }
266 }
267 combineBinaryFiles(foldersOni, listener, log);
268 combineBSLFolders(mods, listener, log);
269
270 copyVideos(log);
271
272 if (unlockLevels.size() > 0) {
273 unlockLevels(unlockLevels, log);
274 }
275
276 Date end = new Date();
277 log.println("Initialization ended at " + sdf.format(end));
278 log.println("Process took "
279 + ((end.getTime() - start.getTime()) / 1000) + " seconds");
280 log.close();
281 }
282
283 private static void combineBSLFolders(TreeSet<Package> mods,
284 InstallProgressListener listener, PrintWriter log) {
285 listener.installProgressUpdate(95, 100, "Installing BSL files");
286 log.println("Installing BSL files");
287
288 HashMap<EBSLInstallType, Vector<Package>> modsToInclude = new HashMap<EBSLInstallType, Vector<Package>>();
289 modsToInclude.put(EBSLInstallType.NORMAL, new Vector<Package>());
290 modsToInclude.put(EBSLInstallType.ADDON, new Vector<Package>());
291
292 for (Package m : mods.descendingSet()) {
293 File bsl = new File(m.getLocalPath(), "bsl");
294 if (bsl.exists()) {
295 if (m.hasSeparatePlatformDirs()) {
296 File bslCommon = new File(bsl, "common");
297 File bslMac = new File(bsl, "mac_only");
298 File bslWin = new File(bsl, "win_only");
299 if ((Settings.getPlatform() == Platform.MACOS && bslMac
300 .exists())
301 || ((Settings.getPlatform() == Platform.WIN || Settings
302 .getPlatform() == Platform.LINUX) && bslWin
303 .exists()) || bslCommon.exists()) {
304 modsToInclude.get(m.getBSLInstallType()).add(m);
305 }
306 } else {
307 modsToInclude.get(m.getBSLInstallType()).add(m);
308 }
309 }
310 }
311
312 for (Package m : modsToInclude.get(EBSLInstallType.NORMAL)) {
313 copyBSL(m, false);
314 }
315 Vector<Package> addons = modsToInclude.get(EBSLInstallType.ADDON);
316 for (int i = addons.size() - 1; i >= 0; i--) {
317 copyBSL(addons.get(i), true);
318 }
319 }
320
321 private static void copyBSL(Package sourceMod, boolean addon) {
322 File targetBaseFolder = new File(Paths.getEditionGDF(), "IGMD");
323 if (!targetBaseFolder.exists())
324 targetBaseFolder.mkdir();
325
326 Vector<File> sources = new Vector<File>();
327 File bsl = new File(sourceMod.getLocalPath(), "bsl");
328 if (sourceMod.hasSeparatePlatformDirs()) {
329 File bslCommon = new File(bsl, "common");
330 File bslMac = new File(bsl, "mac_only");
331 File bslWin = new File(bsl, "win_only");
332 if (Settings.getPlatform() == Platform.MACOS && bslMac.exists()) {
333 for (File f : bslMac.listFiles(dirFileFilter)) {
334 File targetBSL = new File(targetBaseFolder, f.getName());
335 if (addon || !targetBSL.exists())
336 sources.add(f);
337 }
338 }
339 if ((Settings.getPlatform() == Platform.WIN || Settings
340 .getPlatform() == Platform.LINUX) && bslWin.exists()) {
341 for (File f : bslWin.listFiles(dirFileFilter)) {
342 File targetBSL = new File(targetBaseFolder, f.getName());
343 if (addon || !targetBSL.exists())
344 sources.add(f);
345 }
346 }
347 if (bslCommon.exists()) {
348 for (File f : bslCommon.listFiles(dirFileFilter)) {
349 File targetBSL = new File(targetBaseFolder, f.getName());
350 if (addon || !targetBSL.exists())
351 sources.add(f);
352 }
353 }
354 } else {
355 for (File f : bsl.listFiles(dirFileFilter)) {
356 File targetBSL = new File(targetBaseFolder, f.getName());
357 if (addon || !targetBSL.exists())
358 sources.add(f);
359 }
360 }
361
362 System.out.println("For mod: " + sourceMod.getName()
363 + " install BSL folders: " + sources.toString());
364 for (File f : sources) {
365 File targetPath = new File(targetBaseFolder, f.getName());
366 if (!targetPath.exists())
367 targetPath.mkdir();
368 for (File fbsl : f.listFiles()) {
369 File targetFile = new File(targetPath, fbsl.getName());
370 if (addon || !targetFile.exists()) {
371 try {
372 FileUtils.copyFile(fbsl, targetFile);
373 } catch (IOException e) {
374 e.printStackTrace();
375 }
376 }
377 }
378 }
379 }
380
381 private static void combineBinaryFiles(List<File> srcFoldersFiles,
382 InstallProgressListener listener, PrintWriter log) {
383 TreeMap<String, Vector<File>> levels = new TreeMap<String, Vector<File>>();
384
385 for (File path : srcFoldersFiles) {
386 for (File levelF : path.listFiles()) {
387 String fn = levelF.getName().toLowerCase();
388 String levelN = null;
389 if (levelF.isDirectory()) {
390 levelN = fn;
391 } else if (fn.endsWith(".dat")) {
392 levelN = fn.substring(0, fn.lastIndexOf('.'));
393 }
394 if (levelN != null) {
395 if (!levels.containsKey(levelN))
396 levels.put(levelN, new Vector<File>());
397 levels.get(levelN).add(levelF);
398 }
399 }
400 }
401
402 int totalSteps = 0;
403 int stepsDone = 0;
404
405 for (@SuppressWarnings("unused")
406 String s : levels.keySet())
407 totalSteps++;
408 totalSteps++;
409
410 log.println("Importing levels");
411 for (String l : levels.keySet()) {
412 log.println("\tLevel " + l);
413 listener.installProgressUpdate(stepsDone, totalSteps,
414 "Installing level " + l);
415 for (File f : levels.get(l)) {
416 log.println("\t\t\t" + f.getPath());
417 }
418
419 Vector<String> res = OniSplit.packLevel(levels.get(l), new File(
420 Paths.getEditionGDF(), sanitizeLevelName(l) + ".dat"));
421 if (res != null && res.size() > 0) {
422 for (String s : res)
423 log.println("\t\t" + s);
424 }
425
426 log.println();
427 stepsDone++;
428 }
429 }
430
431 private static void copyVideos(PrintWriter log) {
432 if (Settings.getInstance().get("copyintro", false)) {
433 File src = new File(Paths.getVanillaGDF(), "intro.bik");
434 log.println("Copying intro");
435 if (src.exists()) {
436 try {
437 FileUtils.copyFileToDirectory(src, Paths.getEditionGDF());
438 } catch (IOException e) {
439 e.printStackTrace();
440 }
441 }
442 }
443 if (Settings.getInstance().get("copyoutro", true)) {
444 File src = new File(Paths.getVanillaGDF(), "outro.bik");
445 log.println("Copying outro");
446 if (src.exists()) {
447 try {
448 FileUtils.copyFileToDirectory(src, Paths.getEditionGDF());
449 } catch (IOException e) {
450 e.printStackTrace();
451 }
452 }
453 }
454 }
455
456 private static void unlockLevels(TreeSet<Integer> unlockLevels,
457 PrintWriter log) {
458 File dat = new File(Paths.getEditionBasePath(), "persist.dat");
459 log.println("Unlocking levels: " + unlockLevels.toString());
460 if (!dat.exists()) {
461 InputStream is = AEInstaller2.class
462 .getResourceAsStream("/net/oni2/aeinstaller/resources/persist.dat");
463 try {
464 FileUtils.copyInputStreamToFile(is, dat);
465 } catch (IOException e) {
466 // TODO Auto-generated catch block
467 e.printStackTrace();
468 }
469 }
470 PersistDat save = new PersistDat(dat);
471 HashSet<Integer> currentlyUnlocked = save.getUnlockedLevels();
472 currentlyUnlocked.addAll(unlockLevels);
473 save.setUnlockedLevels(currentlyUnlocked);
474 save.close();
475 }
476
477 /**
478 * Initializes the Edition core
479 *
480 * @param listener
481 * Listener for status updates
482 */
483 public static void initializeEdition(InstallProgressListener listener) {
484 File init = new File(Paths.getTempPath(), "init");
485
486 int totalSteps = 0;
487 int stepsDone = 0;
488
489 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
490
491 for (@SuppressWarnings("unused")
492 File f : Paths.getVanillaGDF().listFiles(new FilenameFilter() {
493 @Override
494 public boolean accept(File dir, String name) {
495 return name.endsWith(".dat");
496 }
497 })) {
498 totalSteps++;
499 }
500 totalSteps = totalSteps * 2 + 2;
501
502 try {
503 File logFile = new File(Paths.getInstallerPath(),
504 "Initialization.log");
505 PrintWriter log = new PrintWriter(logFile);
506
507 Date start = new Date();
508 log.println("Initialization of Edition core started at "
509 + sdf.format(start));
510 log.println("Cleaning directories");
511
512 listener.installProgressUpdate(stepsDone, totalSteps,
513 "Cleaning up directories");
514 createEmptyPath(Paths.getVanillaOnisPath());
515 createEmptyPath(init);
516 File level0Folder = new File(init, "level0_Final");
517 createEmptyPath(level0Folder);
518
519 stepsDone++;
520
521 log.println("Exporting levels and moving files to level0");
522
523 for (File f : Paths.getVanillaGDF().listFiles(new FilenameFilter() {
524 @Override
525 public boolean accept(File dir, String name) {
526 return name.endsWith(".dat");
527 }
528 })) {
529 String levelName = f.getName().substring(0,
530 f.getName().indexOf('.'));
531 Scanner fi = new Scanner(levelName);
532 int levelNumber = Integer.parseInt(fi.findInLine("[0-9]+"));
533
534 log.println("\t" + levelName + ":");
535 log.println("\t\tExporting");
536 listener.installProgressUpdate(stepsDone, totalSteps,
537 "Exporting vanilla level " + levelNumber);
538
539 // Edition/GameDataFolder/level*_Final/
540 File tempLevelFolder = new File(init, levelName);
541
542 // Export Vanilla-Level-Dat -> Temp/Level
543 Vector<String> res = OniSplit.export(tempLevelFolder, f);
544 if (res != null && res.size() > 0) {
545 for (String s : res)
546 log.println("\t\t\t" + s);
547 }
548
549 log.println("\t\tMoving files");
550 handleFileGlobalisation(tempLevelFolder, level0Folder,
551 levelNumber);
552 stepsDone++;
553 log.println();
554 }
555
556 log.println("Reimporting levels");
557
558 for (File f : init.listFiles()) {
559 String levelName = f.getName();
560
561 log.println("\t" + levelName);
562 listener.installProgressUpdate(stepsDone, totalSteps,
563 "Creating globalized " + levelName);
564
565 Vector<File> folders = new Vector<File>();
566 folders.add(f);
567
568 Vector<String> res = OniSplit.importLevel(folders, new File(
569 Paths.getVanillaOnisPath(), levelName + ".dat"));
570 if (res != null && res.size() > 0) {
571 for (String s : res)
572 log.println("\t\t" + s);
573 }
574
575 log.println();
576 stepsDone++;
577 }
578
579 listener.installProgressUpdate(stepsDone, totalSteps,
580 "Copying basic files");
581 // Copy Oni-configs
582 File persistVanilla = new File(Paths.getOniBasePath(),
583 "persist.dat");
584 File persistEdition = new File(Paths.getEditionBasePath(),
585 "persist.dat");
586 File keyConfVanilla = new File(Paths.getOniBasePath(),
587 "key_config.txt");
588 File keyConfEdition = new File(Paths.getEditionBasePath(),
589 "key_config.txt");
590 if (persistVanilla.exists() && !persistEdition.exists())
591 FileUtils.copyFile(persistVanilla, persistEdition);
592 if (keyConfVanilla.exists() && !keyConfEdition.exists())
593 FileUtils.copyFile(keyConfVanilla, keyConfEdition);
594
595 FileUtils.deleteDirectory(init);
596
597 Date end = new Date();
598 log.println("Initialization ended at " + sdf.format(end));
599 log.println("Process took "
600 + ((end.getTime() - start.getTime()) / 1000) + " seconds");
601 log.close();
602 } catch (IOException e) {
603 e.printStackTrace();
604 }
605 }
606
607 private static void moveFileToTargetOrDelete(File source, File target) {
608 if (source.equals(target))
609 return;
610 if (!target.exists()) {
611 if (!source.renameTo(target)) {
612 System.err.println("File " + source.getPath() + " not moved!");
613 }
614 } else if (!source.delete()) {
615 System.err.println("File " + source.getPath() + " not deleted!");
616 }
617 }
618
619 private static void handleFileGlobalisation(File tempFolder,
620 File level0Folder, int levelNumber) {
621 // Move AKEV and related files to subfolder so they're not globalized:
622 if (levelNumber != 0) {
623 File akevFolder = new File(tempFolder, "AKEV");
624 akevFolder.mkdir();
625 OniSplit.move(akevFolder, tempFolder.getPath() + "/AKEV*.oni",
626 "overwrite");
627 }
628
629 for (File f : tempFolder.listFiles(new FileFilter() {
630 @Override
631 public boolean accept(File pathname) {
632 return pathname.isFile();
633 }
634 })) {
635 // Move matching files to subfolder NoGlobal:
636 if (f.getName().startsWith("TXMPfail")
637 || f.getName().startsWith("TXMPlevel")
638 || (f.getName().startsWith("TXMP") && f.getName().contains(
639 "intro"))
640 || f.getName().startsWith("TXMB")
641 || f.getName().equals("M3GMpowerup_lsi.oni")
642 || f.getName().equals("TXMPlsi_icon.oni")
643 || (f.getName().startsWith("TXMB") && f.getName().contains(
644 "splash_screen.oni"))) {
645 File noGlobal = new File(tempFolder, "NoGlobal");
646 noGlobal.mkdir();
647 File noGlobalFile = new File(noGlobal, f.getName());
648 moveFileToTargetOrDelete(f, noGlobalFile);
649 }
650 // Move matching files to level0_Animations/level0_TRAC
651 else if (f.getName().startsWith("TRAC")) {
652 File level0File = new File(level0Folder, f.getName());
653 moveFileToTargetOrDelete(f, level0File);
654 }
655 // Move matching files to level0_Animations/level0_TRAM
656 else if (f.getName().startsWith("TRAM")) {
657 File level0File = new File(level0Folder, f.getName());
658 moveFileToTargetOrDelete(f, level0File);
659 }
660 // Move matching files to level0_Textures
661 else if (f.getName().startsWith("ONSK")
662 || f.getName().startsWith("TXMP")) {
663 File level0File = new File(level0Folder, f.getName());
664 moveFileToTargetOrDelete(f, level0File);
665 }
666 // Move matching files to *VANILLA*/level0_Characters
667 else if (f.getName().startsWith("ONCC")
668 || f.getName().startsWith("TRBS")
669 || f.getName().startsWith("ONCV")
670 || f.getName().startsWith("ONVL")
671 || f.getName().startsWith("TRMA")
672 || f.getName().startsWith("TRSC")
673 || f.getName().startsWith("TRAS")) {
674 File level0File = new File(level0Folder, f.getName());
675 moveFileToTargetOrDelete(f, level0File);
676 }
677 // Move matching files to level0_Sounds
678 else if (f.getName().startsWith("OSBD")
679 || f.getName().startsWith("SNDD")) {
680 File level0File = new File(level0Folder, f.getName());
681 moveFileToTargetOrDelete(f, level0File);
682 }
683 // Move matching files to level0_Particles
684 else if (f.getName().startsWith("BINA3")
685 || f.getName().startsWith("M3GMdebris")
686 || f.getName().equals("M3GMtoxic_bubble.oni")
687 || f.getName().startsWith("M3GMelec")
688 || f.getName().startsWith("M3GMrat")
689 || f.getName().startsWith("M3GMjet")
690 || f.getName().startsWith("M3GMbomb_")
691 || f.getName().equals("M3GMbarab_swave.oni")
692 || f.getName().equals("M3GMbloodyfoot.oni")) {
693 File level0File = new File(level0Folder, f.getName());
694 moveFileToTargetOrDelete(f, level0File);
695 }
696 // Move matching files to Archive (aka delete them)
697 else if (f.getName().startsWith("AGDB")
698 || f.getName().startsWith("TRCM")) {
699 f.delete();
700 }
701 // Move matching files to /level0_Final/
702 else if (f.getName().startsWith("ONWC")) {
703 File level0File = new File(level0Folder, f.getName());
704 moveFileToTargetOrDelete(f, level0File);
705 }
706 }
707 }
708
709 private static String sanitizeLevelName(String ln) {
710 int ind = ln.indexOf("_");
711 String res = ln.substring(0, ind + 1);
712 res += ln.substring(ind + 1, ind + 2).toUpperCase();
713 res += ln.substring(ind + 2);
714 return res;
715 }
716
717 /**
718 * Verify that the Edition is within a subfolder to vanilla Oni
719 * (..../Oni/Edition/AEInstaller)
720 *
721 * @return true if GDF can be found in the parent's parent-path
722 */
723 public static boolean verifyRunningDirectory() {
724 return Paths.getVanillaGDF().exists()
725 && Paths.getVanillaGDF().isDirectory();
726 }
727 }