package com.samsung.tizen.common.properties;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
import com.samsung.tizen.common.util.DialogUtil;
import com.samsung.tizen.common.util.HostUtil;
final public class InstallPathConfig {
private static String sdkInstallPath;
- private final static String SDKSUFFIX = File.separatorChar+".TizenSDK"+File.separatorChar+"tizensdkpath";
+ private final static String SDKSUFFIX = ".TizenSDK"+File.separatorChar+"tizensdkpath";
private final static String EMULATOR_PATH = "Emulator";
private final static String INSTALLER_PATH = "InstallManager";
+ // Registry Key
+ private static final String REGISTRY_PATH_OF_SHELL_FOLDER = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
+ // public static final String REGISTRY_APP_DATA_OF_SHELL_FOLDER = "AppData";
+ private static final String REGISTRY_LOCAL_APP_DATA_OF_SHELL_FOLDER = "\"Local AppData\"";
+ // Value Column
+ private static final String REG_SZ = "REG_SZ";
+
static {
// FIXME : don't need the following lines if using environment variable
String sdkPath;
if (OSChecker.isWindows()) {
- sdkPath = System.getenv("localappdata") + File.separatorChar + SDKSUFFIX;
+ String appdataPath = getRegistryValue(REGISTRY_PATH_OF_SHELL_FOLDER,REGISTRY_LOCAL_APP_DATA_OF_SHELL_FOLDER) ;
+ sdkPath = appdataPath + File.separatorChar + SDKSUFFIX;
loadSdkPath(sdkPath);
} else if (OSChecker.isLinux() == true || OSChecker.isUnix() == true || OSChecker.isMAC() == true) {
sdkPath= System.getProperty("user.home") + File.separatorChar + SDKSUFFIX;
System.exit(0);
}
}
-}
-
-
+ private static String getRegistryValue(String node, String key) {
+ if (!OSChecker.isWindows())
+ return null;
+
+ BufferedReader br = null;
+ String value = "";
+
+ String query = "reg query " + "\"" + node + "\" /v " + key;
+ try {
+ Process process = Runtime.getRuntime().exec(query);
+
+ br = new BufferedReader(new InputStreamReader(process.getInputStream(), System.getProperty("file.encoding")));
+
+ String line = null;
+ while((line = br.readLine()) != null) {
+ int index = line.indexOf(REG_SZ);
+ if (index >= 0) {
+ value = line.substring(index + REG_SZ.length()).trim();
+ }
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } finally {
+ if (br != null) {
+ try {
+ br.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return value;
+ }
+}
\ No newline at end of file