source: AE/installer2/src/net/oni2/aeinstaller/backend/oni/Installer.java@ 641

Last change on this file since 641 was 631, checked in by alloc, 12 years ago

AEI2 0.90:

  • Added blank persist.dat for UnlockLevel to always work
  • Made local paths use the sanitized mod-name
  • Added mod-state column to mod table
File size: 21.1 KB
Line 
1package net.oni2.aeinstaller.backend.oni;
2
3import java.io.File;
4import java.io.FileFilter;
5import java.io.FileInputStream;
6import java.io.FileNotFoundException;
7import java.io.FileOutputStream;
8import java.io.FilenameFilter;
9import java.io.IOException;
10import java.io.InputStream;
11import java.io.PrintWriter;
12import java.text.SimpleDateFormat;
13import java.util.Date;
14import java.util.HashMap;
15import java.util.HashSet;
16import java.util.List;
17import java.util.Scanner;
18import java.util.TreeMap;
19import java.util.TreeSet;
20import java.util.Vector;
21
22import net.oni2.aeinstaller.AEInstaller2;
23import net.oni2.aeinstaller.backend.Paths;
24import net.oni2.aeinstaller.backend.Settings;
25import net.oni2.aeinstaller.backend.Settings.Platform;
26import net.oni2.aeinstaller.backend.mods.EBSLInstallType;
27import net.oni2.aeinstaller.backend.mods.Mod;
28import net.oni2.aeinstaller.backend.mods.ModManager;
29
30import org.apache.commons.io.FileUtils;
31
32import com.thoughtworks.xstream.XStream;
33import com.thoughtworks.xstream.io.xml.StaxDriver;
34
35/**
36 * @author Christian Illy
37 */
38public 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 ModManager.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<Mod> tools) {
112 TreeSet<Integer> installed = getInstalledTools();
113 for (Mod 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<Mod> tools) {
141 TreeSet<Integer> installed = getInstalledTools();
142 for (Mod 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<Mod> mods,
208 InstallProgressListener listener) {
209 try {
210 createEmptyPath(Paths.getEditionGDF());
211 } catch (IOException e) {
212 e.printStackTrace();
213 }
214
215 File installCfg = new File(Paths.getEditionGDF(), "installed_mods.xml");
216 ModManager.getInstance().saveModSelection(installCfg, mods);
217
218 HashSet<Integer> unlockLevels = new HashSet<Integer>();
219
220 Vector<File> foldersOni = new Vector<File>();
221 foldersOni.add(Paths.getVanillaOnisPath());
222
223 for (Mod m : mods) {
224 for (int lev : m.getUnlockLevels())
225 unlockLevels.add(lev);
226
227 File oni = new File(m.getLocalPath(), "oni");
228 if (oni.exists()) {
229 if (m.hasSeparatePlatformDirs()) {
230 File oniCommon = new File(oni, "common");
231 File oniMac = new File(oni, "mac_only");
232 File oniWin = new File(oni, "win_only");
233 if (oniCommon.exists())
234 foldersOni.add(oniCommon);
235 if (Settings.getPlatform() == Platform.MACOS
236 && oniMac.exists())
237 foldersOni.add(oniMac);
238 else if (oniWin.exists())
239 foldersOni.add(oniWin);
240 } else {
241 foldersOni.add(oni);
242 }
243 }
244 }
245 combineBinaryFiles(foldersOni, listener);
246 combineBSLFolders(mods, listener);
247
248 copyVideos();
249
250 if (unlockLevels.size() > 0) {
251 unlockLevels(unlockLevels);
252 }
253 }
254
255 private static void combineBSLFolders(TreeSet<Mod> mods,
256 InstallProgressListener listener) {
257 listener.installProgressUpdate(95, 100, "Installing BSL files");
258
259 HashMap<EBSLInstallType, Vector<Mod>> modsToInclude = new HashMap<EBSLInstallType, Vector<Mod>>();
260 modsToInclude.put(EBSLInstallType.NORMAL, new Vector<Mod>());
261 modsToInclude.put(EBSLInstallType.ADDON, new Vector<Mod>());
262
263 for (Mod m : mods.descendingSet()) {
264 File bsl = new File(m.getLocalPath(), "bsl");
265 if (bsl.exists()) {
266 if (m.hasSeparatePlatformDirs()) {
267 File bslCommon = new File(bsl, "common");
268 File bslMac = new File(bsl, "mac_only");
269 File bslWin = new File(bsl, "win_only");
270 if ((Settings.getPlatform() == Platform.MACOS && bslMac
271 .exists())
272 || ((Settings.getPlatform() == Platform.WIN || Settings
273 .getPlatform() == Platform.LINUX) && bslWin
274 .exists()) || bslCommon.exists()) {
275 modsToInclude.get(m.getBSLInstallType()).add(m);
276 }
277 } else {
278 modsToInclude.get(m.getBSLInstallType()).add(m);
279 }
280 }
281 }
282
283 for (Mod m : modsToInclude.get(EBSLInstallType.NORMAL)) {
284 copyBSL(m, false);
285 }
286 Vector<Mod> addons = modsToInclude.get(EBSLInstallType.ADDON);
287 for (int i = addons.size() - 1; i >= 0; i--) {
288 copyBSL(addons.get(i), true);
289 }
290 }
291
292 private static void copyBSL(Mod sourceMod, boolean addon) {
293 File targetBaseFolder = new File(Paths.getEditionGDF(), "IGMD");
294 if (!targetBaseFolder.exists())
295 targetBaseFolder.mkdir();
296
297 Vector<File> sources = new Vector<File>();
298 File bsl = new File(sourceMod.getLocalPath(), "bsl");
299 if (sourceMod.hasSeparatePlatformDirs()) {
300 File bslCommon = new File(bsl, "common");
301 File bslMac = new File(bsl, "mac_only");
302 File bslWin = new File(bsl, "win_only");
303 if (Settings.getPlatform() == Platform.MACOS && bslMac.exists()) {
304 for (File f : bslMac.listFiles(dirFileFilter)) {
305 File targetBSL = new File(targetBaseFolder, f.getName());
306 if (addon || !targetBSL.exists())
307 sources.add(f);
308 }
309 }
310 if ((Settings.getPlatform() == Platform.WIN || Settings
311 .getPlatform() == Platform.LINUX) && bslWin.exists()) {
312 for (File f : bslWin.listFiles(dirFileFilter)) {
313 File targetBSL = new File(targetBaseFolder, f.getName());
314 if (addon || !targetBSL.exists())
315 sources.add(f);
316 }
317 }
318 if (bslCommon.exists()) {
319 for (File f : bslCommon.listFiles(dirFileFilter)) {
320 File targetBSL = new File(targetBaseFolder, f.getName());
321 if (addon || !targetBSL.exists())
322 sources.add(f);
323 }
324 }
325 } else {
326 for (File f : bsl.listFiles(dirFileFilter)) {
327 File targetBSL = new File(targetBaseFolder, f.getName());
328 if (addon || !targetBSL.exists())
329 sources.add(f);
330 }
331 }
332
333 System.out.println("For mod: " + sourceMod.getName()
334 + " install BSL folders: " + sources.toString());
335 for (File f : sources) {
336 File targetPath = new File(targetBaseFolder, f.getName());
337 if (!targetPath.exists())
338 targetPath.mkdir();
339 for (File fbsl : f.listFiles()) {
340 File targetFile = new File(targetPath, fbsl.getName());
341 if (addon || !targetFile.exists()) {
342 try {
343 FileUtils.copyFile(fbsl, targetFile);
344 } catch (IOException e) {
345 e.printStackTrace();
346 }
347 }
348 }
349 }
350 }
351
352 private static void combineBinaryFiles(List<File> srcFoldersFiles,
353 InstallProgressListener listener) {
354 TreeMap<String, Vector<File>> levels = new TreeMap<String, Vector<File>>();
355
356 for (File path : srcFoldersFiles) {
357 for (File levelF : path.listFiles()) {
358 String fn = levelF.getName().toLowerCase();
359 String levelN = null;
360 if (levelF.isDirectory()) {
361 levelN = fn;
362 } else if (fn.endsWith(".dat")) {
363 levelN = fn.substring(0, fn.lastIndexOf('.'));
364 }
365 if (levelN != null) {
366 if (!levels.containsKey(levelN))
367 levels.put(levelN, new Vector<File>());
368 levels.get(levelN).add(levelF);
369 }
370 }
371 }
372
373 int totalSteps = 0;
374 int stepsDone = 0;
375
376 for (@SuppressWarnings("unused")
377 String s : levels.keySet())
378 totalSteps++;
379 totalSteps++;
380
381 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
382
383 File logFile = new File(Paths.getInstallerPath(), "Installation.log");
384 PrintWriter log = null;
385 try {
386 log = new PrintWriter(logFile);
387 } catch (FileNotFoundException e) {
388 e.printStackTrace();
389 }
390
391 Date start = new Date();
392 log.println("Installation of mods started at " + sdf.format(start));
393
394 log.println("Importing levels");
395 for (String l : levels.keySet()) {
396 log.println("\tLevel " + l);
397 listener.installProgressUpdate(stepsDone, totalSteps,
398 "Installing level " + l);
399 for (File f : levels.get(l)) {
400 log.println("\t\t\t" + f.getPath());
401 }
402
403 Vector<String> res = OniSplit.packLevel(levels.get(l), new File(
404 Paths.getEditionGDF(), sanitizeLevelName(l) + ".dat"));
405 if (res != null && res.size() > 0) {
406 for (String s : res)
407 log.println("\t\t" + s);
408 }
409
410 log.println();
411 stepsDone++;
412 }
413
414 Date end = new Date();
415 log.println("Initialization ended at " + sdf.format(end));
416 log.println("Process took "
417 + ((end.getTime() - start.getTime()) / 1000) + " seconds");
418 log.close();
419 }
420
421 private static void copyVideos() {
422 if (Settings.getInstance().get("copyintro", false)) {
423 File src = new File(Paths.getVanillaGDF(), "intro.bik");
424 if (src.exists()) {
425 try {
426 FileUtils.copyFileToDirectory(src, Paths.getEditionGDF());
427 } catch (IOException e) {
428 e.printStackTrace();
429 }
430 }
431 }
432 if (Settings.getInstance().get("copyoutro", true)) {
433 File src = new File(Paths.getVanillaGDF(), "outro.bik");
434 if (src.exists()) {
435 try {
436 FileUtils.copyFileToDirectory(src, Paths.getEditionGDF());
437 } catch (IOException e) {
438 e.printStackTrace();
439 }
440 }
441 }
442 }
443
444 private static void unlockLevels(HashSet<Integer> unlockLevels) {
445 File dat = new File(Paths.getEditionBasePath(), "persist.dat");
446 if (!dat.exists()) {
447 InputStream is = AEInstaller2.class.getResourceAsStream("/net/oni2/aeinstaller/resources/persist.dat");
448 try {
449 FileUtils.copyInputStreamToFile(is, dat);
450 } catch (IOException e) {
451 // TODO Auto-generated catch block
452 e.printStackTrace();
453 }
454 }
455 PersistDat save = new PersistDat(dat);
456 HashSet<Integer> currentlyUnlocked = save.getUnlockedLevels();
457 currentlyUnlocked.addAll(unlockLevels);
458 save.setUnlockedLevels(currentlyUnlocked);
459 save.close();
460 }
461
462 /**
463 * Initializes the Edition core
464 *
465 * @param listener
466 * Listener for status updates
467 */
468 public static void initializeEdition(InstallProgressListener listener) {
469 File init = new File(Paths.getTempPath(), "init");
470
471 int totalSteps = 0;
472 int stepsDone = 0;
473
474 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
475
476 for (@SuppressWarnings("unused")
477 File f : Paths.getVanillaGDF().listFiles(new FilenameFilter() {
478 @Override
479 public boolean accept(File dir, String name) {
480 return name.endsWith(".dat");
481 }
482 })) {
483 totalSteps++;
484 }
485 totalSteps = totalSteps * 2 + 2;
486
487 try {
488 File logFile = new File(Paths.getInstallerPath(),
489 "Initialization.log");
490 PrintWriter log = new PrintWriter(logFile);
491
492 Date start = new Date();
493 log.println("Initialization of Edition core started at "
494 + sdf.format(start));
495 log.println("Cleaning directories");
496
497 listener.installProgressUpdate(stepsDone, totalSteps,
498 "Cleaning up directories");
499 createEmptyPath(Paths.getVanillaOnisPath());
500 createEmptyPath(init);
501 File level0Folder = new File(init, "level0_Final");
502 createEmptyPath(level0Folder);
503
504 stepsDone++;
505
506 log.println("Exporting levels and moving files to level0");
507
508 for (File f : Paths.getVanillaGDF().listFiles(new FilenameFilter() {
509 @Override
510 public boolean accept(File dir, String name) {
511 return name.endsWith(".dat");
512 }
513 })) {
514 String levelName = f.getName().substring(0,
515 f.getName().indexOf('.'));
516 Scanner fi = new Scanner(levelName);
517 int levelNumber = Integer.parseInt(fi.findInLine("[0-9]+"));
518
519 log.println("\t" + levelName + ":");
520 log.println("\t\tExporting");
521 listener.installProgressUpdate(stepsDone, totalSteps,
522 "Exporting vanilla level " + levelNumber);
523
524 // Edition/GameDataFolder/level*_Final/
525 File tempLevelFolder = new File(init, levelName);
526
527 // Export Vanilla-Level-Dat -> Temp/Level
528 Vector<String> res = OniSplit.export(tempLevelFolder, f);
529 if (res != null && res.size() > 0) {
530 for (String s : res)
531 log.println("\t\t\t" + s);
532 }
533
534 log.println("\t\tMoving files");
535 handleFileGlobalisation(tempLevelFolder, level0Folder,
536 levelNumber);
537 stepsDone++;
538 log.println();
539 }
540
541 log.println("Reimporting levels");
542
543 for (File f : init.listFiles()) {
544 String levelName = f.getName();
545
546 log.println("\t" + levelName);
547 listener.installProgressUpdate(stepsDone, totalSteps,
548 "Creating globalized " + levelName);
549
550 Vector<File> folders = new Vector<File>();
551 folders.add(f);
552
553 Vector<String> res = OniSplit.importLevel(folders, new File(
554 Paths.getVanillaOnisPath(), levelName + ".dat"));
555 if (res != null && res.size() > 0) {
556 for (String s : res)
557 log.println("\t\t" + s);
558 }
559
560 log.println();
561 stepsDone++;
562 }
563
564 listener.installProgressUpdate(stepsDone, totalSteps,
565 "Copying basic files");
566 // Copy Oni-configs
567 File persistVanilla = new File(Paths.getOniBasePath(),
568 "persist.dat");
569 File persistEdition = new File(Paths.getEditionBasePath(),
570 "persist.dat");
571 File keyConfVanilla = new File(Paths.getOniBasePath(),
572 "key_config.txt");
573 File keyConfEdition = new File(Paths.getEditionBasePath(),
574 "key_config.txt");
575 if (persistVanilla.exists() && !persistEdition.exists())
576 FileUtils.copyFile(persistVanilla, persistEdition);
577 if (keyConfVanilla.exists() && !keyConfEdition.exists())
578 FileUtils.copyFile(keyConfVanilla, keyConfEdition);
579
580 FileUtils.deleteDirectory(init);
581
582 Date end = new Date();
583 log.println("Initialization ended at " + sdf.format(end));
584 log.println("Process took "
585 + ((end.getTime() - start.getTime()) / 1000) + " seconds");
586 log.close();
587 } catch (IOException e) {
588 e.printStackTrace();
589 }
590 }
591
592 private static void moveFileToTargetOrDelete(File source, File target) {
593 if (source.equals(target))
594 return;
595 if (!target.exists()) {
596 if (!source.renameTo(target)) {
597 System.err.println("File " + source.getPath() + " not moved!");
598 }
599 } else if (!source.delete()) {
600 System.err.println("File " + source.getPath() + " not deleted!");
601 }
602 }
603
604 private static void handleFileGlobalisation(File tempFolder,
605 File level0Folder, int levelNumber) {
606 // Move AKEV and related files to subfolder so they're not globalized:
607 if (levelNumber != 0) {
608 File akevFolder = new File(tempFolder, "AKEV");
609 akevFolder.mkdir();
610 OniSplit.move(akevFolder, tempFolder.getPath() + "/AKEV*.oni",
611 "overwrite");
612 }
613
614 for (File f : tempFolder.listFiles(new FileFilter() {
615 @Override
616 public boolean accept(File pathname) {
617 return pathname.isFile();
618 }
619 })) {
620 // Move matching files to subfolder NoGlobal:
621 if (f.getName().startsWith("TXMPfail")
622 || f.getName().startsWith("TXMPlevel")
623 || (f.getName().startsWith("TXMP") && f.getName().contains(
624 "intro"))
625 || f.getName().startsWith("TXMB")
626 || f.getName().equals("M3GMpowerup_lsi.oni")
627 || f.getName().equals("TXMPlsi_icon.oni")
628 || (f.getName().startsWith("TXMB") && f.getName().contains(
629 "splash_screen.oni"))) {
630 File noGlobal = new File(tempFolder, "NoGlobal");
631 noGlobal.mkdir();
632 File noGlobalFile = new File(noGlobal, f.getName());
633 moveFileToTargetOrDelete(f, noGlobalFile);
634 }
635 // Move matching files to level0_Animations/level0_TRAC
636 else if (f.getName().startsWith("TRAC")) {
637 File level0File = new File(level0Folder, f.getName());
638 moveFileToTargetOrDelete(f, level0File);
639 }
640 // Move matching files to level0_Animations/level0_TRAM
641 else if (f.getName().startsWith("TRAM")) {
642 File level0File = new File(level0Folder, f.getName());
643 moveFileToTargetOrDelete(f, level0File);
644 }
645 // Move matching files to level0_Textures
646 else if (f.getName().startsWith("ONSK")
647 || f.getName().startsWith("TXMP")) {
648 File level0File = new File(level0Folder, f.getName());
649 moveFileToTargetOrDelete(f, level0File);
650 }
651 // Move matching files to *VANILLA*/level0_Characters
652 else if (f.getName().startsWith("ONCC")
653 || f.getName().startsWith("TRBS")
654 || f.getName().startsWith("ONCV")
655 || f.getName().startsWith("ONVL")
656 || f.getName().startsWith("TRMA")
657 || f.getName().startsWith("TRSC")
658 || f.getName().startsWith("TRAS")) {
659 File level0File = new File(level0Folder, f.getName());
660 moveFileToTargetOrDelete(f, level0File);
661 }
662 // Move matching files to level0_Sounds
663 else if (f.getName().startsWith("OSBD")
664 || f.getName().startsWith("SNDD")) {
665 File level0File = new File(level0Folder, f.getName());
666 moveFileToTargetOrDelete(f, level0File);
667 }
668 // Move matching files to level0_Particles
669 else if (f.getName().startsWith("BINA3")
670 || f.getName().startsWith("M3GMdebris")
671 || f.getName().equals("M3GMtoxic_bubble.oni")
672 || f.getName().startsWith("M3GMelec")
673 || f.getName().startsWith("M3GMrat")
674 || f.getName().startsWith("M3GMjet")
675 || f.getName().startsWith("M3GMbomb_")
676 || f.getName().equals("M3GMbarab_swave.oni")
677 || f.getName().equals("M3GMbloodyfoot.oni")) {
678 File level0File = new File(level0Folder, f.getName());
679 moveFileToTargetOrDelete(f, level0File);
680 }
681 // Move matching files to Archive (aka delete them)
682 else if (f.getName().startsWith("AGDB")
683 || f.getName().startsWith("TRCM")) {
684 f.delete();
685 }
686 // Move matching files to /level0_Final/
687 else if (f.getName().startsWith("ONWC")) {
688 File level0File = new File(level0Folder, f.getName());
689 moveFileToTargetOrDelete(f, level0File);
690 }
691 }
692 }
693
694 private static String sanitizeLevelName(String ln) {
695 int ind = ln.indexOf("_");
696 String res = ln.substring(0, ind + 1);
697 res += ln.substring(ind + 1, ind + 2).toUpperCase();
698 res += ln.substring(ind + 2);
699 return res;
700 }
701
702 /**
703 * Verify that the Edition is within a subfolder to vanilla Oni
704 * (..../Oni/Edition/AEInstaller)
705 *
706 * @return true if GDF can be found in the parent's parent-path
707 */
708 public static boolean verifyRunningDirectory() {
709 return Paths.getVanillaGDF().exists()
710 && Paths.getVanillaGDF().isDirectory();
711 }
712}
Note: See TracBrowser for help on using the repository browser.