]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Modify Extract() function to speed up the Far installation.
authorqouyang <qouyang@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 12 Oct 2006 10:19:59 +0000 (10:19 +0000)
committerqouyang <qouyang@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 12 Oct 2006 10:19:59 +0000 (10:19 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1729 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Far.java

index 6dbf1afd4086ee689d43ecf86e608e878080b314..ad04dc7fcdb836256e2e5e843b6e556e763a50c9 100644 (file)
@@ -154,39 +154,6 @@ public class Far {
         return true;\r
     }\r
 \r
         return true;\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
     public void extract(List<FarFileItem> allFile, String dir) throws Exception {\r
 \r
         Iterator filesItem = allFile.iterator();\r
@@ -213,28 +180,30 @@ public class Far {
                         // Read the entry data and write it to the output\r
                         // file.\r
                         //\r
                         // Read the entry data and write it to the output\r
                         // file.\r
                         //\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
-                            fos.write(buffer);\r
-                            size = entryStream.read(buffer);\r
+                        int fileLen = (int)je.getSize();\r
+                        byte[] buffer = new byte[fileLen];\r
+                        int len = entryStream.read(buffer);\r
+                        if (len < fileLen){\r
+                            File tempFile = new File("tempFile");\r
+                            FileOutputStream fos = new FileOutputStream(tempFile);\r
+                            fos.write(buffer, 0, len);\r
+                            while (len < fileLen){\r
+                                int tempLen = entryStream.read(buffer);\r
+                                len = len + tempLen;\r
+                                fos.write(buffer, 0, tempLen);\r
+                            }\r
+                            fos.close();\r
+                            FileInputStream fin = new FileInputStream(tempFile);\r
+                            fin.read(buffer);\r
+                            tempFile.delete();\r
                         }\r
                         }\r
-\r
-                        fos.close();\r
-                        byte[] totalBuffer = new byte[(int) tempFile.length()];\r
-                        FileInputStream fis = new FileInputStream(tempFile);\r
-                        fis.read(totalBuffer);\r
                         //\r
                         //  Check Md5\r
                         //\r
                         //\r
                         //  Check Md5\r
                         //\r
-                        if (!ffItem.getMd5Value().equalsIgnoreCase(FarMd5.md5(totalBuffer))){\r
+                        if (!ffItem.getMd5Value().equalsIgnoreCase(FarMd5.md5(buffer))){\r
                             throw new Exception (ffItem.getRelativeFilename() + " MD5 Checksum is invaild!");\r
                         }\r
                             throw new Exception (ffItem.getRelativeFilename() + " MD5 Checksum is invaild!");\r
                         }\r
-                        outputStream.write(totalBuffer);\r
-                        fis.close();\r
-                        tempFile.delete();\r
+                        outputStream.write(buffer);\r
                     } finally {\r
                         outputStream.close();\r
                     }\r
                     } finally {\r
                         outputStream.close();\r
                     }\r