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.Settings.Platform; |
10 |
|
11 |
/** |
12 |
* @author Christian Illy |
13 |
*/ |
14 |
public class DotNet { |
15 |
|
16 |
/** |
17 |
* @return is a .NET implementation installed? |
18 |
*/ |
19 |
public static boolean isInstalled() { |
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 |
e.printStackTrace(); |
35 |
} catch (IllegalAccessException e) { |
36 |
e.printStackTrace(); |
37 |
} catch (InvocationTargetException e) { |
38 |
e.printStackTrace(); |
39 |
} catch (Exception e) { |
40 |
if (!e.getMessage() |
41 |
.equals("Registry access not supported (not a Windows OS?).")) |
42 |
e.printStackTrace(); |
43 |
} |
44 |
return false; |
45 |
case MACOS: |
46 |
case LINUX: |
47 |
Vector<String> cmd = new Vector<String>(); |
48 |
cmd.add("which"); |
49 |
cmd.add("mono"); |
50 |
Vector<String> res = null; |
51 |
try { |
52 |
res = AppExecution.executeAndWait(cmd); |
53 |
} catch (IOException e) { |
54 |
e.printStackTrace(); |
55 |
} |
56 |
if (res != null) { |
57 |
if (res.get(0).startsWith("/") |
58 |
&& res.get(0).endsWith("mono")) { |
59 |
return true; |
60 |
} |
61 |
} |
62 |
return false; |
63 |
default: |
64 |
return false; |
65 |
} |
66 |
} |
67 |
|
68 |
/** |
69 |
* @return Get the .Net runtime executable name |
70 |
*/ |
71 |
public static String getRuntimeExe() { |
72 |
if (Settings.getPlatform() != Platform.WIN) |
73 |
return "mono"; |
74 |
return ""; |
75 |
} |
76 |
|
77 |
} |