]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Far.java
1. Update release note to use jdk1.5.0_06 to take place of jdk1.5.0_04
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / far / Far.java
index d550d220ac0b200719a4d007047d5b2dc497c261..57116334f2fd9a1ded4082b49da10ba0ffb2cc86 100644 (file)
@@ -62,10 +62,9 @@ public class Far {
         jf = farFile;\r
         this.mainfest = new Mainfest(getMainfestFile());\r
     }\r
-    \r
-    public void creatFar (List<PackageIdentification> pkgList,\r
-            List<PlatformIdentification> plfList, Set<String> fileFilter,\r
-            FarHeader fHeader) throws Exception{\r
+\r
+    public void creatFar(List<PackageIdentification> pkgList, List<PlatformIdentification> plfList,\r
+                         Set<String> fileFilter, FarHeader fHeader) throws Exception {\r
         jos = new JarOutputStream(new FileOutputStream(jarFile));\r
 \r
         //\r
@@ -94,23 +93,28 @@ public class Far {
         }\r
         jos.close();\r
     }\r
-    \r
-    private void writeToJar(File file, JarOutputStream jos) throws Exception{\r
-      byte[] buffer = new byte[(int)file.length()];\r
-      FileInputStream fInput = new FileInputStream(file);\r
-      JarEntry entry = new JarEntry(Tools.convertPathToUnixType(Tools.getRelativePath(file.getPath(),Workspace.getCurrentWorkspace())));\r
-      jos.putNextEntry(entry);\r
-      fInput.read(buffer);\r
-      jos.write(buffer);\r
-      fInput.close();\r
+\r
+    private void writeToJar(File file, JarOutputStream jos) throws Exception {\r
+        byte[] buffer = new byte[(int) file.length()];\r
+        FileInputStream fInput = new FileInputStream(file);\r
+        JarEntry entry = new JarEntry(\r
+                                      Tools\r
+                                           .convertPathToUnixType(Tools\r
+                                                                       .getRelativePath(file.getPath(),\r
+                                                                                        Workspace.getCurrentWorkspace())));\r
+        jos.putNextEntry(entry);\r
+        fInput.read(buffer);\r
+        jos.write(buffer);\r
+        fInput.close();\r
     }\r
 \r
     public void InstallFar(String dir) throws Exception {\r
         List<FarFileItem> allFile = mainfest.getAllFileItem();\r
         extract(allFile, dir);\r
     }\r
-    \r
-    public void InstallFar (Map<PlatformIdentification, File> plfMap, Map<PackageIdentification, File> pkgMap) throws Exception{\r
+\r
+    public void InstallFar(Map<PlatformIdentification, File> plfMap, Map<PackageIdentification, File> pkgMap)\r
+                                                                                                             throws Exception {\r
         Set<PlatformIdentification> plfKeys = plfMap.keySet();\r
         Iterator<PlatformIdentification> plfIter = plfKeys.iterator();\r
         while (plfIter.hasNext()) {\r
@@ -149,39 +153,40 @@ public class Far {
     public boolean hibernateToFile() {\r
         return true;\r
     }\r
-//    public static void main(String[] args){\r
-//        try {\r
-//            JarFile jarFile = new JarFile(new File("C:\\cvswork\\newEdk\\jar.jar.far"));\r
-//            JarEntry je= jarFile.getJarEntry("MdePkg/MdePkg.spd");\r
-//            InputStream is = jarFile.getInputStream(je);\r
-//            byte[] buffer = new byte[1];      \r
-//            File tempFile = new File("C:\\cvswork\\newEdk\\tempFile");\r
-//            File tfile2 = new File("C:\\cvswork\\newEdk\\tempFile1");\r
-//            FileOutputStream fos1 = new FileOutputStream(tfile2);\r
-//            FileOutputStream fos = new FileOutputStream(tempFile);\r
-//            int size = is.read(buffer);\r
-//            int totoalSize = size;\r
-//            while ( size >=  0) {\r
-//                fos.write(buffer);\r
-//                size = is.read(buffer);\r
-//                totoalSize = totoalSize + size;\r
-//            }\r
-//            \r
-//            \r
-////            is = jarFile.getInputStream(je);\r
-////            is.read(totalbuffer);\r
-////            fos.write(totalbuffer);\r
-//            fos.close();\r
-//            byte[] totalbuffer = new byte[(int)tempFile.length()];\r
-//            FileInputStream fis = new FileInputStream(tempFile);\r
-//            fis.read(totalbuffer);\r
-//            fos1.write(totalbuffer);\r
-//            fos1.close();\r
-//        }catch(Exception e){\r
-//            \r
-//        }\r
-//    }\r
-    \r
+\r
+    //    public static void main(String[] args){\r
+    //        try {\r
+    //            JarFile jarFile = new JarFile(new File("C:\\cvswork\\newEdk\\jar.jar.far"));\r
+    //            JarEntry je= jarFile.getJarEntry("MdePkg/MdePkg.spd");\r
+    //            InputStream is = jarFile.getInputStream(je);\r
+    //            byte[] buffer = new byte[1];      \r
+    //            File tempFile = new File("C:\\cvswork\\newEdk\\tempFile");\r
+    //            File tfile2 = new File("C:\\cvswork\\newEdk\\tempFile1");\r
+    //            FileOutputStream fos1 = new FileOutputStream(tfile2);\r
+    //            FileOutputStream fos = new FileOutputStream(tempFile);\r
+    //            int size = is.read(buffer);\r
+    //            int totoalSize = size;\r
+    //            while ( size >=  0) {\r
+    //                fos.write(buffer);\r
+    //                size = is.read(buffer);\r
+    //                totoalSize = totoalSize + size;\r
+    //            }\r
+    //            \r
+    //            \r
+    ////            is = jarFile.getInputStream(je);\r
+    ////            is.read(totalbuffer);\r
+    ////            fos.write(totalbuffer);\r
+    //            fos.close();\r
+    //            byte[] totalbuffer = new byte[(int)tempFile.length()];\r
+    //            FileInputStream fis = new FileInputStream(tempFile);\r
+    //            fis.read(totalbuffer);\r
+    //            fos1.write(totalbuffer);\r
+    //            fos1.close();\r
+    //        }catch(Exception e){\r
+    //            \r
+    //        }\r
+    //    }\r
+\r
     public void extract(List<FarFileItem> allFile, String dir) throws Exception {\r
 \r
         Iterator filesItem = allFile.iterator();\r
@@ -191,7 +196,7 @@ public class Far {
         dir += File.separatorChar;\r
         while (filesItem.hasNext()) {\r
             try {\r
-                ffItem = (FarFileItem)filesItem.next();\r
+                ffItem = (FarFileItem) filesItem.next();\r
                 je = jf.getJarEntry(Tools.convertPathToUnixType(ffItem.getDefaultPath()));\r
                 InputStream entryStream = jf.getInputStream(je);\r
                 File file = new File(dir + ffItem.getRelativeFilename());\r
@@ -202,24 +207,23 @@ public class Far {
                     // exists).\r
                     //\r
                     FileOutputStream outputStream = new FileOutputStream(file);\r
-                    \r
 \r
                     try {\r
                         //\r
                         // Read the entry data and write it to the output\r
                         // file.\r
                         //\r
-                        byte[] buffer = new byte[1];      \r
+                        byte[] buffer = new byte[1];\r
                         File tempFile = new File("tempFile");\r
                         FileOutputStream fos = new FileOutputStream(tempFile);\r
                         int size = entryStream.read(buffer);\r
-                        while ( size >=  0) {\r
+                        while (size >= 0) {\r
                             fos.write(buffer);\r
                             size = entryStream.read(buffer);\r
                         }\r
-                        \r
+\r
                         fos.close();\r
-                        byte[] totalBuffer = new byte[(int)tempFile.length()];\r
+                        byte[] totalBuffer = new byte[(int) tempFile.length()];\r
                         FileInputStream fis = new FileInputStream(tempFile);\r
                         fis.read(totalBuffer);\r
                         outputStream.write(totalBuffer);\r
@@ -235,12 +239,11 @@ public class Far {
             } finally {\r
             }\r
         }\r
-                        \r
-     }\r
-    \r
-    \r
-    public void addFileToFar (File file, JarOutputStream farOuputStream, String workDir){\r
-        \r
+\r
+    }\r
+\r
+    public void addFileToFar(File file, JarOutputStream farOuputStream, String workDir) {\r
+\r
     }\r
 \r
     /**\r
@@ -254,6 +257,9 @@ public class Far {
         List<PackageIdentification> result = new ArrayList<PackageIdentification>();\r
 \r
         entry = this.mainfest.getPackgeSpd(pkgId);\r
+        if (entry == null) {\r
+            return result;\r
+        }\r
         if (entry[0] != null) {\r
             try {\r
                 JarEntry je;\r