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

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

AEI: OniSplit / globalization

File size: 1.5 KB
Line 
1package net.oni2.aeinstaller.backend.oni;
2
3import java.io.File;
4import java.io.FilenameFilter;
5import java.io.IOException;
6import java.util.Scanner;
7
8import net.oni2.aeinstaller.backend.Paths;
9
10import org.apache.commons.io.FileUtils;
11
12/**
13 * @author Christian Illy
14 */
15public class Installer {
16 /**
17 * @return Is Edition Core initialized
18 */
19 public static boolean isEditionInitialized() {
20 File editionGDF = Paths.getEditionGDF();
21 File vanillaDats = Paths.getVanillaGDF();
22 return editionGDF.exists() && vanillaDats.exists();
23 }
24
25 private static void createEmptyPath(File path) throws IOException {
26 if (path.exists())
27 FileUtils.deleteDirectory(path);
28 path.mkdirs();
29 }
30
31 /**
32 * Initializes the Edition core
33 */
34 public static void initializeEdition() {
35 File init = new File(Paths.getTempPath(), "init");
36 try {
37 createEmptyPath(Paths.getEditionGDF());
38 createEmptyPath(Paths.getVanillaOnisPath());
39 createEmptyPath(init);
40
41 for (File f : Paths.getVanillaGDF().listFiles(new FilenameFilter() {
42 @Override
43 public boolean accept(File dir, String name) {
44 return name.endsWith(".dat");
45 }
46 })) {
47 String levelName = f.getName().substring(0,
48 f.getName().indexOf('.'));
49 int levelNumber = -1;
50
51 Scanner fi = new Scanner(levelName);
52 fi.useDelimiter("[^\\p{Alnum}]");
53 while (fi.hasNextInt()) {
54 levelNumber = fi.nextInt();
55 }
56
57 OniSplit.export(new File(init, levelName), f);
58 }
59
60 // TODO: FileUtils.deleteDirectory(Paths.getEditionGDF());
61 } catch (IOException e) {
62 e.printStackTrace();
63 }
64 }
65}
Note: See TracBrowser for help on using the repository browser.