X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;ds=sidebyside;f=Tools%2FSource%2FFrameworkWizard%2Fsrc%2Forg%2Ftianocore%2Fframeworkwizard%2Ffar%2FFar.java;h=57116334f2fd9a1ded4082b49da10ba0ffb2cc86;hb=ef6e2efe66135410d8e7f63a6291260bf7c36596;hp=21a86f5789651dbd8830c8d427ef87240964ee66;hpb=5a24e806b0d343b2a847996f4758ed2a06a363fb;p=mirror_edk2.git diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Far.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Far.java index 21a86f5789..57116334f2 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Far.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Far.java @@ -154,6 +154,39 @@ public class Far { return true; } + // public static void main(String[] args){ + // try { + // JarFile jarFile = new JarFile(new File("C:\\cvswork\\newEdk\\jar.jar.far")); + // JarEntry je= jarFile.getJarEntry("MdePkg/MdePkg.spd"); + // InputStream is = jarFile.getInputStream(je); + // byte[] buffer = new byte[1]; + // File tempFile = new File("C:\\cvswork\\newEdk\\tempFile"); + // File tfile2 = new File("C:\\cvswork\\newEdk\\tempFile1"); + // FileOutputStream fos1 = new FileOutputStream(tfile2); + // FileOutputStream fos = new FileOutputStream(tempFile); + // int size = is.read(buffer); + // int totoalSize = size; + // while ( size >= 0) { + // fos.write(buffer); + // size = is.read(buffer); + // totoalSize = totoalSize + size; + // } + // + // + //// is = jarFile.getInputStream(je); + //// is.read(totalbuffer); + //// fos.write(totalbuffer); + // fos.close(); + // byte[] totalbuffer = new byte[(int)tempFile.length()]; + // FileInputStream fis = new FileInputStream(tempFile); + // fis.read(totalbuffer); + // fos1.write(totalbuffer); + // fos1.close(); + // }catch(Exception e){ + // + // } + // } + public void extract(List allFile, String dir) throws Exception { Iterator filesItem = allFile.iterator(); @@ -164,10 +197,6 @@ public class Far { while (filesItem.hasNext()) { try { ffItem = (FarFileItem) filesItem.next(); - // Enumeration a = jf.entries(); - // while (a.hasMoreElements()) { - // System.out.println("##" + a.nextElement().getName()); - // } je = jf.getJarEntry(Tools.convertPathToUnixType(ffItem.getDefaultPath())); InputStream entryStream = jf.getInputStream(je); File file = new File(dir + ffItem.getRelativeFilename()); @@ -184,14 +213,22 @@ public class Far { // Read the entry data and write it to the output // file. // - int size = entryStream.available(); - byte[] buffer = new byte[size]; - outputStream.write(buffer); - // if (!(FarMd5.md5(buffer)).equalsIgnoreCase(ffItem.getMd5Value())){ - // throw new Exception (je.getName() + " Md5 is invalided!"); - // } - - // System.out.println(je.getName() + " extracted."); + byte[] buffer = new byte[1]; + File tempFile = new File("tempFile"); + FileOutputStream fos = new FileOutputStream(tempFile); + int size = entryStream.read(buffer); + while (size >= 0) { + fos.write(buffer); + size = entryStream.read(buffer); + } + + fos.close(); + byte[] totalBuffer = new byte[(int) tempFile.length()]; + FileInputStream fis = new FileInputStream(tempFile); + fis.read(totalBuffer); + outputStream.write(totalBuffer); + fis.close(); + tempFile.delete(); } finally { outputStream.close(); } @@ -200,24 +237,11 @@ public class Far { } } finally { - //jf.close(); } } } - // public void installFarPackage (PackageIdentification pkgId, String dir) throws Exception{ - // String pkgDir = null; - // List farFileList = new ArrayList(); - // farFileList = this.mainfest.getPackageContents(pkgId); - // if (dir == null){ - // pkgDir = this.mainfest.getPackageDefaultPath(pkgId); - // }else { - // pkgDir = dir; - // } - // extract(farFileList,pkgDir); - // } - public void addFileToFar(File file, JarOutputStream farOuputStream, String workDir) { } @@ -233,6 +257,9 @@ public class Far { List result = new ArrayList(); entry = this.mainfest.getPackgeSpd(pkgId); + if (entry == null) { + return result; + } if (entry[0] != null) { try { JarEntry je;