1 | package net.oni2.aeinstaller.backend;
|
---|
2 |
|
---|
3 | import java.io.IOException;
|
---|
4 | import java.lang.reflect.InvocationTargetException;
|
---|
5 | import java.util.Map;
|
---|
6 | import java.util.Vector;
|
---|
7 |
|
---|
8 | import net.oni2.aeinstaller.backend.Settings.Architecture;
|
---|
9 | import net.oni2.aeinstaller.backend.app_launcher.QuickAppExecution;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * @author Christian Illy
|
---|
13 | */
|
---|
14 | public class OniSplit {
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * @return is a .NET implementation installed?
|
---|
18 | */
|
---|
19 | public static boolean isDotNETInstalled() {
|
---|
20 | switch (Settings.getPlatform()) {
|
---|
21 | case WIN:
|
---|
22 | try {
|
---|
23 | int view = WinRegistry.KEY_WOW64_32KEY;
|
---|
24 | if (Settings.getArchitecture() == Architecture.AMD64)
|
---|
25 | view = WinRegistry.KEY_WOW64_64KEY;
|
---|
26 |
|
---|
27 | Map<String, String> m = WinRegistry
|
---|
28 | .readStringValues(
|
---|
29 | WinRegistry.HKEY_LOCAL_MACHINE,
|
---|
30 | "Software\\Microsoft\\NET Framework Setup\\NDP\\v2.0.50727",
|
---|
31 | view);
|
---|
32 | return m != null;
|
---|
33 | } catch (IllegalArgumentException e) {
|
---|
34 | // TODO Auto-generated catch block
|
---|
35 | e.printStackTrace();
|
---|
36 | } catch (IllegalAccessException e) {
|
---|
37 | // TODO Auto-generated catch block
|
---|
38 | e.printStackTrace();
|
---|
39 | } catch (InvocationTargetException e) {
|
---|
40 | // TODO Auto-generated catch block
|
---|
41 | e.printStackTrace();
|
---|
42 | } catch (Exception e) {
|
---|
43 | if (!e.getMessage()
|
---|
44 | .equals("Registry access not supported (not a Windows OS?)."))
|
---|
45 | // TODO Auto-generated catch block
|
---|
46 | e.printStackTrace();
|
---|
47 | }
|
---|
48 | return false;
|
---|
49 | case MACOS:
|
---|
50 | case LINUX:
|
---|
51 | Vector<String> cmd = new Vector<String>();
|
---|
52 | cmd.add("which");
|
---|
53 | cmd.add("mono");
|
---|
54 | Vector<String> res = null;
|
---|
55 | try {
|
---|
56 | res = QuickAppExecution.execute(cmd);
|
---|
57 | } catch (IOException e) {
|
---|
58 | // TODO Auto-generated catch block
|
---|
59 | e.printStackTrace();
|
---|
60 | }
|
---|
61 | if (res != null) {
|
---|
62 | if (res.get(0).startsWith("/")
|
---|
63 | && res.get(0).endsWith("mono")) {
|
---|
64 | return true;
|
---|
65 | }
|
---|
66 | }
|
---|
67 | return false;
|
---|
68 | default:
|
---|
69 | return false;
|
---|
70 | }
|
---|
71 | }
|
---|
72 | }
|
---|