Project

General

Profile

Download (1.13 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
 * Copyright (C) 2009 EDIT
4
 * European Distributed Institute of Taxonomy
5
 * http://www.e-taxonomy.eu
6
 *
7
 * The contents of this file are subject to the Mozilla Public License Version 1.1
8
 * See LICENSE.TXT at the top of this package for the full license terms.
9
 */
10
package eu.etaxonomy.cdm.server;
11

    
12
/**
13
 * @author andreas
14
 * @date Jul 17, 2012
15
 *
16
 */
17
public class OsChecker {
18

    
19
    public boolean isMac() {
20
        try {
21
            Class.forName("com.apple.eawt.Application");
22
            return true;
23
        } catch (Exception e) {
24
            return false;
25
        }
26
    }
27

    
28
    // can be defeated by creating a cmd.exe in PATH
29
    public boolean isWin() {
30
        try {
31
            Runtime.getRuntime().exec(new String[] { "cmd.exe", "/C", "dir" }).waitFor();
32
            return true;
33
        } catch (Exception e) {
34
            return false;
35
        }
36
    }
37

    
38
    public boolean isLinux() {
39
        if (isMac())
40
            return false;
41
        try {
42
            Runtime.getRuntime().exec(new String[] { "sh", "-c", "ls" }).waitFor();
43
            return true;
44
        } catch (Exception e) {
45
            return false;
46
        }
47
    }
48

    
49
}
(6-6/6)