• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.ddmlib;
18 
19 public final class DdmConstants {
20 
21     public final static int PLATFORM_UNKNOWN = 0;
22     public final static int PLATFORM_LINUX = 1;
23     public final static int PLATFORM_WINDOWS = 2;
24     public final static int PLATFORM_DARWIN = 3;
25 
26     /**
27      * Returns current platform, one of {@link #PLATFORM_WINDOWS}, {@link #PLATFORM_DARWIN},
28      * {@link #PLATFORM_LINUX} or {@link #PLATFORM_UNKNOWN}.
29      */
30     public final static int CURRENT_PLATFORM = currentPlatform();
31 
32     /**
33      * Extension for Traceview files.
34      */
35     public final static String DOT_TRACE = ".trace";
36 
37     /** hprof-conv executable (with extension for the current OS)  */
38     public final static String FN_HPROF_CONVERTER = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ?
39             "hprof-conv.exe" : "hprof-conv"; //$NON-NLS-1$ //$NON-NLS-2$
40 
41     /** traceview executable (with extension for the current OS)  */
42     public final static String FN_TRACEVIEW = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ?
43             "traceview.bat" : "traceview"; //$NON-NLS-1$ //$NON-NLS-2$
44 
45     /**
46      * Returns current platform
47      *
48      * @return one of {@link #PLATFORM_WINDOWS}, {@link #PLATFORM_DARWIN},
49      * {@link #PLATFORM_LINUX} or {@link #PLATFORM_UNKNOWN}.
50      */
currentPlatform()51     public static int currentPlatform() {
52         String os = System.getProperty("os.name");          //$NON-NLS-1$
53         if (os.startsWith("Mac OS")) {                      //$NON-NLS-1$
54             return PLATFORM_DARWIN;
55         } else if (os.startsWith("Windows")) {              //$NON-NLS-1$
56             return PLATFORM_WINDOWS;
57         } else if (os.startsWith("Linux")) {                //$NON-NLS-1$
58             return PLATFORM_LINUX;
59         }
60 
61         return PLATFORM_UNKNOWN;
62     }
63 
64 }
65