package org.tizen.dynamicanalyzer.common.path;
-import java.io.BufferedReader;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-import org.eclipse.core.runtime.Platform;
+import org.tizen.common.core.application.InstallPathConfig;
import org.tizen.dynamicanalyzer.util.CommonUtil;
// All paths of PathManager should not be ended with File.separater
public class PathManager {
private static String logPostFix = null;
- private static final String SDK_INFO_RELATIVE_PATH = "../../sdk.info"; //$NON-NLS-1$
-
// tizen paths
- public static final String TIZEN_SDK_DATA_PATH = getTizenSdkDataPath();
public static final String TIZEN_SDK_INSTALL_PATH = getTizenSdkInstallPath();
+ public static final String TIZEN_SDK_DATA_PATH = getTizenSdkDataPath();
// sdb path
- public static final String SDB_PATH = TIZEN_SDK_INSTALL_PATH
- + File.separator + PathConstants.TOOLS_FOLDER_NAME + File.separator
- + "sdb"; //$NON-NLS-1$
+ public static final String SDB_PATH = InstallPathConfig.getSDBPath(); //$NON-NLS-1$
// dynamic analyzer paths
- public static final String DA_DATA_PATH = TIZEN_SDK_DATA_PATH
- + File.separator + PathConstants.DYNAMIC_ANALYZER_FOLDER_NAME;
- public static final String DA_INSTALL_PATH = TIZEN_SDK_INSTALL_PATH
- + File.separator + PathConstants.TOOLS_FOLDER_NAME + File.separator
+ public static final String DA_DATA_PATH = TIZEN_SDK_DATA_PATH + File.separator
+ PathConstants.DYNAMIC_ANALYZER_FOLDER_NAME;
- public static final String DA_AUTOTEST_PATH = TIZEN_SDK_DATA_PATH
- + File.separator + "test" + File.separator
+ public static final String DA_INSTALL_PATH = TIZEN_SDK_INSTALL_PATH + File.separator
+ + PathConstants.TOOLS_FOLDER_NAME + File.separator
+ PathConstants.DYNAMIC_ANALYZER_FOLDER_NAME;
- public static final String DA_READELF_PATH = DA_INSTALL_PATH
- + File.separator + PathConstants.TARGET_FOLDER_NAME;
+ public static final String DA_AUTOTEST_PATH = TIZEN_SDK_DATA_PATH + File.separator
+ + "test" + File.separator + PathConstants.DYNAMIC_ANALYZER_FOLDER_NAME;
+ public static final String DA_READELF_PATH = DA_INSTALL_PATH + File.separator
+ + PathConstants.TARGET_FOLDER_NAME;
public static final String DA_LOG_PATH = DA_DATA_PATH + File.separator
+ PathConstants.LOGS_FOLDER_NAME;
+ PathConstants.SETTING_FOLDER_NAME;
public static final String DA_RPM_PATH = DA_DATA_PATH + File.separator
+ PathConstants.RPM_FOLDER_NAME;
- public static final String DA_CONFIG_FOLDER_PATH = DA_INSTALL_PATH
- + File.separator + PathConstants.CONFIG_FOLDER_NAME;
- public static final String DA_TOOL_FOLDER_PATH = DA_INSTALL_PATH
- + File.separator + PathConstants.TOOL_FOLDER_NAME;
+ public static final String DA_CONFIG_FOLDER_PATH = DA_INSTALL_PATH + File.separator
+ + PathConstants.CONFIG_FOLDER_NAME;
+ public static final String DA_TOOL_FOLDER_PATH = DA_INSTALL_PATH + File.separator
+ + PathConstants.TOOL_FOLDER_NAME;
public static final String DA_DEBUG_DATA_CHANNEL_LOG_FILE = DA_LOG_PATH
+ File.separator + "data.log"; //$NON-NLS-1$
public static final String DA_DEBUG_CONTROL_CHANNEL_LOG_FILE = DA_LOG_PATH
+ File.separator + "control.log"; //$NON-NLS-1$
- public static final String DA_TEMP_FOLDER_PATH = DA_SAVE_PATH
- + File.separator + PathConstants.TEMP_FOLDER_NAME;
- public static final String DA_BINARY_AUTO_SAVE_FILE = DA_SAVE_PATH
- + File.separator + "BinarySettings.save";
+ public static final String DA_TEMP_FOLDER_PATH = DA_SAVE_PATH + File.separator
+ + PathConstants.TEMP_FOLDER_NAME;
+ public static final String DA_BINARY_AUTO_SAVE_FILE = DA_SAVE_PATH + File.separator
+ + "BinarySettings.save";
- public static final String IDE_ACTIVE_PORT_PATH = DA_SAVE_PATH
- + File.separator + "active_da_plugin"; //$NON-NLS-1$
- public static final String IDE_ACTIVE_SAVE_PORT_PATH = DA_SAVE_PATH
- + File.separator + "current_active_ide_port"; //$NON-NLS-1$
+ public static final String IDE_ACTIVE_PORT_PATH = DA_SAVE_PATH + File.separator
+ + "active_da_plugin"; //$NON-NLS-1$
+ public static final String IDE_ACTIVE_SAVE_PORT_PATH = DA_SAVE_PATH + File.separator
+ + "current_active_ide_port"; //$NON-NLS-1$
public static boolean checkTizenPathValidation() {
if (TIZEN_SDK_DATA_PATH == null || TIZEN_SDK_INSTALL_PATH == null) {
return logPostFix;
}
- private static String getRegistryValue(String node, String key) {
- BufferedReader br = null;
- String value = "";
-
- String query = "reg query " + "\"" + node + "\" /v " + "\"" + key + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- try {
- Process process = Runtime.getRuntime().exec(query);
- String encoding = System.getProperty("sun.jnu.encoding"); //$NON-NLS-1$
-
- br = new BufferedReader(new InputStreamReader(
- process.getInputStream(), encoding));
-
- String line = null;
- while ((line = br.readLine()) != null) {
- int index = line.indexOf("REG_SZ"); //$NON-NLS-1$
- if (index >= 0) {
- value = line.substring(index + "REG_SZ".length()).trim(); //$NON-NLS-1$
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- CommonUtil.tryClose(br);
- }
- return value;
- }
-
- private static String getPathFromSdkInfoFile(boolean isDataPath) {
- String retPath = null;
- BufferedReader br = null;
-
- try {
- String curpath = null;
- curpath = Platform.getInstallLocation().getURL().getPath();
- if (null != curpath && !curpath.isEmpty()) {
- String sdkinfoPath = curpath + SDK_INFO_RELATIVE_PATH;
- File sdkinfoFile = new File(sdkinfoPath);
- if (sdkinfoFile.exists() && sdkinfoFile.isFile()) {
- br = new BufferedReader(new InputStreamReader(
- new FileInputStream(sdkinfoFile)));
-
- String line = br.readLine(); // sdk install path
- if (isDataPath) {
- line = br.readLine(); // sdk data path
- }
- if (line != null) {
- retPath = line.substring(line.indexOf("=") + 1);
- }
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- if (null != br) {
- try {
- br.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
- return retPath;
- }
-
public static String getTizenSdkDataPath() {
String defaultPath = null;
- // case 1 : read from sdk.info
- defaultPath = getPathFromSdkInfoFile(true);
-
- // case 2 : get default install directory
- if (null == defaultPath || defaultPath.isEmpty()) {
- if (CommonUtil.isLinux()) {
- defaultPath = System.getenv(PathConstants.LINUX_INSTALL_ENV)
- + File.separator + PathConstants.TIZEN_SDK_DATA;
- } else if (CommonUtil.isWin()) {
- defaultPath = getRegistryValue(PathConstants.WIN_INSTALL_NODE,
- PathConstants.WIN_INSTALL_KEY)
- + File.separator
- + PathConstants.TIZEN_SDK_DATA;
- } else if (CommonUtil.isMac()) {
- defaultPath = System.getenv(PathConstants.LINUX_INSTALL_ENV)
- + File.separator + PathConstants.TIZEN_SDK_DATA;
- } else {
- defaultPath = "";
- }
- }
+ defaultPath = InstallPathConfig.getUserDataPath();
File file = new File(defaultPath);
if (file == null || !file.exists()) {
}
public static String getTizenSdkInstallPath() {
- String retPath = null;
- BufferedReader br = null;
-
- // case 1 : sdk.info
- retPath = getPathFromSdkInfoFile(false);
-
- // case 2 : tizensdkpath in tizen-sdk-data directory
- if (null == retPath || retPath.isEmpty()) {
- try {
- String infoPath = TIZEN_SDK_DATA_PATH + File.separator
- + PathConstants.INSTALLATION_INFO;
- File file = new File(infoPath);
- if (file.exists() && file.isFile()) {
- br = new BufferedReader(new InputStreamReader(
- new FileInputStream(file)));
- String line = br.readLine();
- if (null != line) {
- retPath = line.substring(line.indexOf("=") + 1);
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- if (null != br) {
- try {
- br.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
+ String defaultPath = null;
+
+ defaultPath = InstallPathConfig.getSDKPath();
+
+ File file = new File(defaultPath);
+ if (file == null || !file.exists()) {
+ defaultPath = null;
}
- return retPath;
+ return defaultPath;
}
// get tizen header file directory in sdk local rootstraps
public static String getTargetPath(String platform) {
if (null != platform && !platform.isEmpty()) {
return TIZEN_SDK_INSTALL_PATH + File.separator
- + PathConstants.PLATFORM_FOLDER_NAME + File.separator
- + platform + File.separator
- + PathConstants.DYNAMIC_ANALYZER_FOLDER_NAME
+ + PathConstants.PLATFORM_FOLDER_NAME + File.separator + platform
+ + File.separator + PathConstants.DYNAMIC_ANALYZER_FOLDER_NAME
+ File.separator;
} else {
- return DA_INSTALL_PATH + File.separator
- + PathConstants.TARGET_FOLDER_NAME + File.separator;
+ return DA_INSTALL_PATH + File.separator + PathConstants.TARGET_FOLDER_NAME
+ + File.separator;
}
}
@Override
public boolean accept(File dir, String name) {
- return name
- .contains(PathConstants.BASE_PLATFORM_PLUGIN_FOLDER_NAME);
+ return name.contains(PathConstants.BASE_PLATFORM_PLUGIN_FOLDER_NAME);
}
});
} else {
return "";
}
- String aboutFilePath = aboutFolderPath + File.separator
- + files[files.length - 1] + File.separator
- + PathConstants.ABOUT_FILE_NAME;
+ String aboutFilePath = aboutFolderPath + File.separator + files[files.length - 1]
+ + File.separator + PathConstants.ABOUT_FILE_NAME;
return aboutFilePath;
}
@Override
public boolean accept(File dir, String name) {
- return name
- .contains(PathConstants.WORKBENCH_PLUGIN_FOLDER_NAME);
+ return name.contains(PathConstants.WORKBENCH_PLUGIN_FOLDER_NAME);
}
});
} else {
return "";
}
- String aboutFilePath = aboutFolderPath + File.separator
- + files[files.length - 1];
+ String aboutFilePath = aboutFolderPath + File.separator + files[files.length - 1];
return aboutFilePath;
}
public static String getRootstrapsPath(String platform) {
if (platform != null) {
return TIZEN_SDK_INSTALL_PATH + File.separator
- + PathConstants.PLATFORM_FOLDER_NAME + File.separator
- + platform + File.separator
- + PathConstants.TIZEN_FOLDER_ROOTSTRAPS;
+ + PathConstants.PLATFORM_FOLDER_NAME + File.separator + platform
+ + File.separator + PathConstants.TIZEN_FOLDER_ROOTSTRAPS;
} else {
return "";
}