1
|
/**
|
2
|
* Copyright (C) 2009 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.server;
|
10
|
|
11
|
/**
|
12
|
* @author andreas
|
13
|
* @date Jul 17, 2012
|
14
|
*/
|
15
|
public class OsChecker {
|
16
|
|
17
|
public boolean isMac() {
|
18
|
try {
|
19
|
Class.forName("com.apple.eawt.Application");
|
20
|
return true;
|
21
|
} catch (Exception e) {
|
22
|
return false;
|
23
|
}
|
24
|
}
|
25
|
|
26
|
// can be defeated by creating a cmd.exe in PATH
|
27
|
public boolean isWin() {
|
28
|
try {
|
29
|
Runtime.getRuntime().exec(new String[] { "cmd.exe", "/C", "dir" }).waitFor();
|
30
|
return true;
|
31
|
} catch (Exception e) {
|
32
|
return false;
|
33
|
}
|
34
|
}
|
35
|
|
36
|
public boolean isLinux() {
|
37
|
if (isMac()) {
|
38
|
return false;
|
39
|
}
|
40
|
try {
|
41
|
Runtime.getRuntime().exec(new String[] { "sh", "-c", "ls" }).waitFor();
|
42
|
return true;
|
43
|
} catch (Exception e) {
|
44
|
return false;
|
45
|
}
|
46
|
}
|
47
|
|
48
|
}
|