import java.io.File;
import java.io.IOException;
+import java.net.URISyntaxException;
+
+import org.tizen.emulator.manager.EmulatorManager;
public class FileIO {
- File dir1 = new File(".");
- File dir2 = new File("..");
- File dir3 = new File("../../");
private final static String arch_suffix = File.separator +"x86";
private final static String icon_suffix = File.separator +"skins"+ File.separator +"icons" + File.separator +"vtm.ico";
private final static String data_suffix = File.separator +"data";
private final static String conf_suffix = File.separator +"conf";
private final static String vms_suffix = File.separator +".tizen_vms";
private final static String baseimg_suffix = File.separator +"emulimg-1.0.x86";
+ private final static String bios_suffix = File.separator + "pc-bios";
private final static String etc_suffix = File.separator +"etc";
private final static String log_suffix = File.separator +"logs";
private final static String x86_kernel_suffix = File.separator +"kernel-img";
+ private static String currentPath;
+ private static String emulatorPath;
+ private static String sdkPath;
+
+ private static String sdbPath;
+ // Emulator
+ private static String binPath;
+ private static String arcPath;
+ private static String iconPath;
+ private static String dataPath;
+ private static String confPath;
+ private static String baseImagePath;
+ private static String etcPath;
+ private static String x86KernelPath;
+ private static String biosPath;
+
+ private static String vmsPath;
+ private static String vmsArchPath;
+
+ static {
+ // emulator-manager.jar file path
+ {
+ File jar = null;
+ try {
+ jar = new File(EmulatorManager.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
+ } catch (URISyntaxException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ currentPath = jar.getParent();
+ }
+
+ emulatorPath = currentPath + File.separator + "..";
+ sdkPath = emulatorPath + File.separator + "..";
+
+ // SDB path
+ {
+ String sdb_suffix;
+ if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1)
+ sdb_suffix = File.separator +"SDK" + File.separator + "sdb" + File.separator + "sdb.exe";
+ else
+ sdb_suffix = File.separator +"SDK" + File.separator + "sdb" + File.separator + "sdb";
+
+ sdbPath = sdkPath + sdb_suffix;
+ }
+
+ binPath = currentPath;
+ arcPath = emulatorPath + arch_suffix;
+ etcPath = emulatorPath + etc_suffix;
+ iconPath = emulatorPath + icon_suffix;
+
+ dataPath = arcPath + data_suffix;
+ confPath = arcPath + conf_suffix;
+ baseImagePath = arcPath + baseimg_suffix;
+
+ x86KernelPath = dataPath + x86_kernel_suffix;
+ biosPath = dataPath + bios_suffix;
+ vmsPath = System.getProperty("user.home") + vms_suffix;
+ vmsArchPath = vmsPath + arch_suffix;
+
+ }
+
+ public static void testPrintPath() {
+ System.out.println(currentPath);
+ System.out.println(emulatorPath);
+ System.out.println(sdkPath);
+ System.out.println(sdbPath);
+ System.out.println(binPath);
+ System.out.println(arcPath);
+ System.out.println(etcPath);
+ System.out.println(iconPath);
+ System.out.println(dataPath);
+ System.out.println(confPath);
+ System.out.println(x86KernelPath);
+ System.out.println(biosPath);
+ System.out.println(vmsPath);
+ System.out.println(vmsArchPath);
+
+ }
+
static FileIO instance = null;
static {
}
public String getSdkRoot() throws IOException {
- return dir3.getCanonicalPath();
- }
-
+ return sdkPath;
+ }
+
public String getSdbPath() throws IOException {
- String sdb_suffix;
- String root_dir = getSdkRoot();
- StringBuffer sb = new StringBuffer(root_dir);
- if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1)
- sdb_suffix = File.separator +"SDK" + File.separator + "sdb" + File.separator + "sdb.exe";
- else
- sdb_suffix = File.separator +"SDK" + File.separator + "sdb" + File.separator + "sdb";
-
- return sb.append(sdb_suffix).toString();
+ return sdbPath;
}
public String getBinPath() throws IOException {
- String temp = dir1.getCanonicalPath();
- return temp;
- //return dir1.getCanonicalPath();
+ return binPath;
}
public String getArchPath() throws IOException {
- String temp = dir2.getCanonicalPath();
- StringBuffer sb = new StringBuffer(temp);
- return sb.append(arch_suffix).toString();
+ return arcPath;
}
// ~/tizen_sdk/Emulator/skins/icons/vtm.ico
public String getIconPath() throws IOException {
- String temp = dir2.getCanonicalPath();
- StringBuffer sb = new StringBuffer(temp);
- return sb.append(icon_suffix).toString();
+ return iconPath;
}
public String getDataPath() throws IOException {
- String temp = getArchPath();
- StringBuffer sb = new StringBuffer(temp);
- return sb.append(data_suffix).toString();
+ return dataPath;
}
public String getConfPath() throws IOException {
- String temp = getArchPath();
- StringBuffer sb = new StringBuffer(temp);
- return sb.append(conf_suffix).toString();
+ return confPath;
}
public String getTizenVmsPath() {
- String temp = System.getProperty("user.home");
- StringBuffer sb = new StringBuffer(temp);
- return sb.append(vms_suffix).toString();
- //return EmulatorVMs.getInstance().getVMsBaseDirectory();
+ return vmsPath;
}
public String getTizenVmsArchPath() {
- return getTizenVmsPath() + arch_suffix;
+ return vmsArchPath;
}
public String getBaseimgPath() throws IOException{
- String temp = getArchPath();
- StringBuffer sb = new StringBuffer(temp);
- return sb.append(baseimg_suffix).toString();
+ return baseImagePath;
}
public String getEtcPath() throws IOException {
- String temp = dir2.getCanonicalPath();
- StringBuffer sb = new StringBuffer(temp);
- return sb.append(etc_suffix).toString();
+ return etcPath;
}
public String getKernelPath() throws IOException {
- String temp = getDataPath();
- StringBuffer sb = new StringBuffer(temp);
- return sb.append(x86_kernel_suffix).toString();
+ return x86KernelPath;
}
+ // ~/tizen_sdk/Emulator/x86/data/pc-bios/bios.bin
+ public String getBiosPath() {
+ return biosPath;
+ }
+
public String getVirtualTargetPath(String name) {
- return getTizenVmsArchPath() + File.separator +"" + name;
+ return getTizenVmsArchPath() + File.separator + name;
}
public String getVirtualTargetLogPath(String name) {