[Title] modfiy file path problem
authorjihye kim <jihye1128.kim@samsung.com>
Fri, 16 Mar 2012 08:05:55 +0000 (17:05 +0900)
committerjihye kim <jihye1128.kim@samsung.com>
Fri, 16 Mar 2012 08:05:55 +0000 (17:05 +0900)
[Type] bug fix
[Module] emulator manager
[Priority] major
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

package/pkginfo.manifest
src/org/tizen/emulator/manager/tool/FileIO.java
src/org/tizen/emulator/manager/tool/Launcher.java
src/org/tizen/emulator/manager/vt/VirtualTargetProcess.java

index 5d35b64..fda5f50 100644 (file)
@@ -1,5 +1,5 @@
 Package: emulator-manager
-Version: 1.0.5
+Version: 1.0.6
 OS: linux
 Build-host-os: linux
 Maintainer: Yeong-Kyoon Lee<yeongkyoon.lee@samsung.com>
@@ -7,7 +7,7 @@ Source: emulator-manager
 Description: Tizen Emulator Manager
 
 Package: emulator-manager
-Version: 1.0.5
+Version: 1.0.6
 OS: windows
 Build-host-os: windows
 Maintainer: Yeong-Kyoon Lee<yeongkyoon.lee@samsung.com>
index 5ab3305..3f15b1c 100644 (file)
@@ -2,21 +2,102 @@ package org.tizen.emulator.manager.tool;
 
 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 {
@@ -29,82 +110,60 @@ public class FileIO {
        }
        
        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) {
index fd2732f..b456fc0 100644 (file)
@@ -192,7 +192,7 @@ public class Launcher {
                        cmd.add("-bios");
                        cmd.add("bios.bin");
                        cmd.add("-L");
-                       cmd.add("../x86/data/pc-bios");
+                       cmd.add(fio.getBiosPath());
                        cmd.add("-kernel");
                        cmd.add(fio.getKernelPath() + File.separator+ "bzImage");
                        cmd.add("-net");
@@ -204,6 +204,7 @@ public class Launcher {
                //      cmd.add("tcp:1202:10.0.2.16:22");
                        //System.out.println(cmd);
                        ProcessBuilder pb = new ProcessBuilder(cmd);
+                       pb.directory(new File(fio.getBinPath()));
                        
                        Process process = pb.start();
 
index 55751d6..6a874e1 100644 (file)
@@ -40,7 +40,7 @@ class Process {
        private   String errorMessage;
 
        public Process() {
-               filePath = new FileIO();
+               filePath = FileIO.getInstance();
                errorMessage = "Throw unknown error";
        }
 
@@ -290,7 +290,8 @@ class CreateVirtualTargetProcess extends Process {
                
                String exe_path;
                try {
-                       exe_path = filePath.getSdkRoot() + SEFARATOR + "Emulator" + SEFARATOR + "bin"  + SEFARATOR + "qemu-img";
+                       //exe_path = filePath.getSdkRoot() + SEFARATOR + "Emulator" + SEFARATOR + "bin"  + SEFARATOR + "qemu-img";
+                       exe_path = filePath.getBinPath() + SEFARATOR + "qemu-img";
                } catch (IOException e1) {
                        e1.printStackTrace();
                        return false;