import java.io.BufferedReader;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import org.tizen.emulator.manager.EmulatorManager;
public class FilePathResources {
private final static String sdk_suffix = ".." + File.separator + ".." + File.separator + ".."; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private final static String bin_suffix = File.separator + "bin"; //$NON-NLS-1$
+ private final static String bin_suffix = File.separator + "bin"; //$NON-NLS-1$
private final static String tool_suffix = File.separator + "tools"; //$NON-NLS-1$
private final static String emulator_suffix = File.separator + "emulator"; //$NON-NLS-1$
- private final static String platform_suffix = File.separator + "platforms"; //$NON-NLS-1$
- private final static String em_images_suffix = File.separator + "emulator-images"; //$NON-NLS-1$
- private final static String resource_suffix = File.separator + "emulator-resources"; //$NON-NLS-1$
+ private final static String platform_suffix = File.separator + "platforms"; //$NON-NLS-1$
+ private final static String em_images_suffix = File.separator
+ + "emulator-images"; //$NON-NLS-1$
+ private final static String resource_suffix = File.separator
+ + "emulator-resources"; //$NON-NLS-1$
private final static String common_suffix = File.separator + "common"; //$NON-NLS-1$
private final static String platform_prefix = File.separator + "tizen-"; //$NON-NLS-1$
private final static String etc_suffix = File.separator + "etc"; //$NON-NLS-1$
private final static String remote_suffix = File.separator + "remote"; //$NON-NLS-1$
private final static String bios_suffix = File.separator + "bios"; //$NON-NLS-1$
- private final static String kernel_suffix = File.separator +"kernel"; //$NON-NLS-1$
+ private final static String kernel_suffix = File.separator + "kernel"; //$NON-NLS-1$
private final static String swap_suffix = File.separator + "swap"; //$NON-NLS-1$
- private final static String data_suffix = File.separator +"data"; //$NON-NLS-1$
+ private final static String data_suffix = File.separator + "data"; //$NON-NLS-1$
private final static String images_suffix = File.separator + "images"; //$NON-NLS-1$
private final static String win_sdb_exec = File.separator + "sdb.exe"; //$NON-NLS-1$
private final static String sdb_exec = File.separator + "sdb"; //$NON-NLS-1$
- private final static String sdkpath_suffix = File.separator + "tizensdkpath"; //$NON-NLS-1$
- private final static String sdkdata_suffix = File.separator + "tizen-sdk-data"; //$NON-NLS-1$
+ private final static String sdkpath_suffix = File.separator
+ + "tizensdkpath"; //$NON-NLS-1$
+ private final static String sdkdata_suffix = File.separator
+ + "tizen-sdk-data"; //$NON-NLS-1$
private final static String storages_suffix = File.separator + "storages"; //$NON-NLS-1$
private final static String sdcard_suffix = File.separator + "sdcard"; //$NON-NLS-1$
private final static String skins_suffix = File.separator + "skins"; //$NON-NLS-1$
private final static String template2_suffix = File.separator + "template2"; //$NON-NLS-1$
private final static String plugins_suffix = File.separator + "plugins"; //$NON-NLS-1$
- private final static String sdkdata_new_emulator_suffix = File.separator + "emulator"; //$NON-NLS-1$
+ private final static String sdkdata_new_emulator_suffix = File.separator
+ + "emulator"; //$NON-NLS-1$
private final static String vms_suffix = File.separator + "vms"; //$NON-NLS-1$
private final static String qemuImg_suffix = File.separator + "qemu-img"; //$NON-NLS-1$
private final static String checkCam_suffix = File.separator + "check-cam" //$NON-NLS-1$
- + (EmulatorManager.isWin() ? ".exe" : "") ; //$NON-NLS-1$ //$NON-NLS-2$
+ + (EmulatorManager.isWin() ? ".exe" : ""); //$NON-NLS-1$ //$NON-NLS-2$
// Tizen SDK
private static String currentPath;
private static String sdkDataSdcardPath;
private static String sdkDataSwapPath;
- private final static String log_suffix = File.separator +"logs"; //$NON-NLS-1$
+ private final static String log_suffix = File.separator + "logs"; //$NON-NLS-1$
private static String tizensdkdataPath;
private static String tizensdkdataEmulatorPath;;
private static String sdkDataVmsPath;
{
File jar = null;
try {
- jar = new File(EmulatorManager.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
+ jar = new File(EmulatorManager.class.getProtectionDomain()
+ .getCodeSource().getLocation().toURI().getPath());
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (sdkPath == null) {
- sdkPath = currentPath;
+ sdkPath = currentPath;
}
String toolsPath = ""; //$NON-NLS-1$
}
try {
- toolEmulatorPath = new File(toolsPath + emulator_suffix).getCanonicalPath();
+ toolEmulatorPath = new File(toolsPath + emulator_suffix)
+ .getCanonicalPath();
} catch (IOException e) {
toolEmulatorPath = toolsPath + emulator_suffix;
}
toolEmulatorBinPath = toolEmulatorPath + bin_suffix;
- toolEmulatorEtcPath = toolEmulatorPath + etc_suffix;
+ toolEmulatorEtcPath = toolEmulatorPath + etc_suffix;
toolEmulatorRemotePath = toolEmulatorPath + remote_suffix;
sdkDataSdcardPath = toolEmulatorPath + storages_suffix + sdcard_suffix;
sdkDataSwapPath = toolEmulatorPath + storages_suffix + swap_suffix;
- tizensdkdataEmulatorPath = tizensdkdataPath + sdkdata_new_emulator_suffix;
+ tizensdkdataEmulatorPath = tizensdkdataPath
+ + sdkdata_new_emulator_suffix;
sdcardPath = tizensdkdataEmulatorPath + sdcard_suffix;
-// swapPath = tizensdkdataEmulatorPath + swap_suffix;
+ // swapPath = tizensdkdataEmulatorPath + swap_suffix;
swapPath = sdkDataSwapPath;
sdkDataVmsPath = tizensdkdataEmulatorPath + vms_suffix;
private static String findSDKDataPath() {
String dataPath = null;
// read sdk.info file
- File sdkInfoFile = new File(currentPath + File.separator + sdk_suffix + sdkinfo_suffix);
+ File sdkInfoFile = new File(currentPath + File.separator + sdk_suffix
+ + sdkinfo_suffix);
if (sdkInfoFile.exists()) {
- EMLogger.addStaticLog("sdk.info file path: " + sdkInfoFile); //$NON-NLS-1$
- BufferedReader in = null;
- try {
- in = new BufferedReader(new FileReader(sdkInfoFile));
- } catch (FileNotFoundException e) {
- EMLogger.getLogger().warning(e.getMessage());
- }
- String s = null;;
- try {
- while((s = in.readLine()) != null) {
- int i = s.indexOf("="); //$NON-NLS-1$
- if (i != -1) {
- String s1 = s.substring(0, i);
- String s2 = s.substring(i+1, s.length());
- if (s1.equals("TIZEN_SDK_INSTALLED_PATH")) { //$NON-NLS-1$
- sdkPath = s2;
- EMLogger.addStaticLog("TIZEN_SDK_INSTALLED_PATH: " //$NON-NLS-1$
- + sdkPath);
- } else if (s1.equals("TIZEN_SDK_DATA_PATH")) { //$NON-NLS-1$
- dataPath = s2;
- EMLogger.addStaticLog("TIZEN_SDK_DATA_PATH: " //$NON-NLS-1$
- + dataPath);
- }
+ EMLogger.addStaticLog("sdk.info file path: " + sdkInfoFile); //$NON-NLS-1$
+ BufferedReader in = null;
+ try {
+ in = new BufferedReader(new InputStreamReader(
+ new FileInputStream(sdkInfoFile), "UTF-8"));
+ } catch (FileNotFoundException | UnsupportedEncodingException e) {
+ EMLogger.getLogger().warning(
+ "Failed to open sdk.info file : " + e.getMessage());
+ return null;
+ }
+
+ String s = null;
+ try {
+ while ((s = in.readLine()) != null) {
+ int i = s.indexOf("="); //$NON-NLS-1$
+ if (i != -1) {
+ String s1 = s.substring(0, i);
+ String s2 = s.substring(i + 1, s.length());
+ if (s1.equals("TIZEN_SDK_INSTALLED_PATH")) { //$NON-NLS-1$
+ sdkPath = s2;
+ EMLogger.addStaticLog("TIZEN_SDK_INSTALLED_PATH: " //$NON-NLS-1$
+ + sdkPath);
+ } else if (s1.equals("TIZEN_SDK_DATA_PATH")) { //$NON-NLS-1$
+ dataPath = s2;
+ EMLogger.addStaticLog("TIZEN_SDK_DATA_PATH: " //$NON-NLS-1$
+ + dataPath);
}
}
- } catch (IOException e) {
- EMLogger.addStaticLog(e.getMessage());
}
+ } catch (IOException e) {
+ EMLogger.addStaticLog(e.getMessage());
+ }
- try {
- in.close();
- } catch (IOException e) {
- EMLogger.addStaticLog(e.getMessage());
- }
+ try {
+ in.close();
+ } catch (IOException e) {
+ EMLogger.addStaticLog(e.getMessage());
+ }
}
if (dataPath == null || dataPath.isEmpty()) {
try {
in = new BufferedReader(new FileReader(f));
String s;
- while((s = in.readLine()) != null) {
+ while ((s = in.readLine()) != null) {
int i = s.indexOf("="); //$NON-NLS-1$
if (i != -1) {
- String s2 = s.substring(i+1, s.length());
+ String s2 = s.substring(i + 1, s.length());
sdkPath = s2;
}
}
static FilePathResources instance = null;
static {
- synchronized(FilePathResources.class) {
+ synchronized (FilePathResources.class) {
instance = new FilePathResources();
}
}
private FilePathResources() {
}
- public static String getSdkRoot(){
+ public static String getSdkRoot() {
return sdkPath;
}
- public static String getSdbPath(){
+ public static String getSdbPath() {
return sdbPath;
}
return toolEmulatorPath;
}
- public static String getToolEmulatorBinPath(){
+ public static String getToolEmulatorBinPath() {
return toolEmulatorBinPath;
}
// emulator common check tool
public static String getEmulatorCheckToolPath() {
- return getToolEmulatorBinPath();
+ return getToolEmulatorBinPath();
}
public static String getEmulatorQemuImgPath() {
}
try {
emulatorPath = new File(platformsPath + platform_prefix
- + platformVersion + common_suffix + emulator_suffix).getCanonicalPath();
+ + platformVersion + common_suffix + emulator_suffix)
+ .getCanonicalPath();
} catch (IOException e) {
- emulatorPath = platformsPath + platform_prefix
- + platformVersion + common_suffix + emulator_suffix;
+ emulatorPath = platformsPath + platform_prefix + platformVersion
+ + common_suffix + emulator_suffix;
}
return emulatorPath;
}
public static String getSwapPath() {
return swapPath;
}
+
public static String getbaseSwapPath() {
return sdkDataSwapPath;
}
}
public static String getPlatformTemplate2Path() {
- return platformTemplate2Path ;
+ return platformTemplate2Path;
}
public static String getPlatformPluginsPath() {
if (path != null) {
String arr[] = path.split("\\.");
if (arr.length > 1) {
- return arr[arr.length-1];
+ return arr[arr.length - 1];
}
}
return "";