01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.harmony.misc;
18:
19: /**
20: * Some system utils
21: *
22: * @author Alexey A. Petrenko
23: * @version $Revision: 1.1.6.3 $
24: */
25: public class SystemUtils {
26: // Public constants
27: // OSes
28: public static final int OS_WINDOWS = 1;
29: public static final int OS_LINUX = 2;
30: public static final int OS_UNKNOWN = -1;
31:
32: // Architectures
33: public static final int ARC_IA32 = 1;
34: public static final int ARC_IA64 = 2;
35: public static final int ARC_UNKNOWN = -1;
36:
37: // Private fields
38: private static int os = 0;
39:
40: // Public interface
41: public static int getOS() {
42: if (os == 0) {
43: String osname = System.getProperty("os.name").substring(0,
44: 3);
45: if (osname.compareToIgnoreCase("win") == 0) {
46: os = OS_WINDOWS;
47: } else {
48: if (osname.compareToIgnoreCase("lin") == 0) {
49: os = OS_LINUX;
50: } else
51: os = OS_UNKNOWN;
52: }
53: }
54: return os;
55: }
56: }
|