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 /** hprof-conv executable (with extension for the current OS) */ 33 public final static String FN_HPROF_CONVERTER = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ? 34 "hprof-conv.exe" : "hprof-conv"; //$NON-NLS-1$ //$NON-NLS-2$ 35 36 /** traceview executable (with extension for the current OS) */ 37 public final static String FN_TRACEVIEW = (CURRENT_PLATFORM == PLATFORM_WINDOWS) ? 38 "traceview.bat" : "traceview"; //$NON-NLS-1$ //$NON-NLS-2$ 39 40 /** 41 * Returns current platform 42 * 43 * @return one of {@link #PLATFORM_WINDOWS}, {@link #PLATFORM_DARWIN}, 44 * {@link #PLATFORM_LINUX} or {@link #PLATFORM_UNKNOWN}. 45 */ currentPlatform()46 public static int currentPlatform() { 47 String os = System.getProperty("os.name"); //$NON-NLS-1$ 48 if (os.startsWith("Mac OS")) { //$NON-NLS-1$ 49 return PLATFORM_DARWIN; 50 } else if (os.startsWith("Windows")) { //$NON-NLS-1$ 51 return PLATFORM_WINDOWS; 52 } else if (os.startsWith("Linux")) { //$NON-NLS-1$ 53 return PLATFORM_LINUX; 54 } 55 56 return PLATFORM_UNKNOWN; 57 } 58 59 } 60