X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FFrameworkTasks%2Forg%2Ftianocore%2Fframework%2Ftasks%2FCompressSection.java;h=84f9176e786f7a120b9eae62eff8bb45a3fbe044;hp=8def4ebc95908cfb4d9504415d2b514f500000ab;hb=87379bbecf036195249649680b958e501dc952a5;hpb=878ddf1fc3540a715f63594ed22b6929e881afb4 diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressSection.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressSection.java index 8def4ebc95..84f9176e78 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressSection.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressSection.java @@ -17,11 +17,8 @@ package org.tianocore.framework.tasks; -import java.io.DataInputStream; +import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -54,18 +51,17 @@ public class CompressSection implements Section, FfsTypes{ @param Buffer The point of output buffer **/ - public void toBuffer (DataOutputStream Buffer){ + public void toBuffer (DataOutputStream buffer){ Section sect; - File compressOut; // // Get section file in compress node. // try{ - compressOut = new File ("Compress.temp"); - FileOutputStream fo = new FileOutputStream (compressOut.getName()); - DataOutputStream Do = new DataOutputStream (fo); + + ByteArrayOutputStream bo = new ByteArrayOutputStream (); + DataOutputStream Do = new DataOutputStream (bo); // // Get each section which under the compress {}; @@ -89,17 +85,10 @@ public class CompressSection implements Section, FfsTypes{ } Do.close(); - // - // Get contain to Buffer - // - FileInputStream fi = new FileInputStream (compressOut.getName()); - DataInputStream di = new DataInputStream (fi); - byte[] fileBuffer = new byte[(int)compressOut.length()]; - di.read(fileBuffer); - // // Call compress // + byte[] fileBuffer = bo.toByteArray(); Compress myCompress = new Compress(fileBuffer, fileBuffer.length); // @@ -121,7 +110,7 @@ public class CompressSection implements Section, FfsTypes{ Ch.SectionHeader.type = (byte) EFI_SECTION_COMPRESSION; // - // Note: The compressName was not effective now. Using the + // Note: The compressName was not efsfective now. Using the // EFI_STANDARD_COMPRSSION for compressType . // That is follow old Genffsfile tools. Some code will be added for // the different compressName; @@ -138,24 +127,23 @@ public class CompressSection implements Section, FfsTypes{ // // First add CompressHeader to Buffer, then add Compress data. // - Buffer.write (headerBuffer); - Buffer.write(myCompress.outputBuffer); + buffer.write (headerBuffer); + buffer.write(myCompress.outputBuffer); // - // 4 Byte aligment + // Buffer 4 Byte aligment // int size = Ch.GetSize() + myCompress.outputBuffer.length; while ((size & 0x03) != 0){ size ++; - Buffer.writeByte(0); + buffer.writeByte(0); } - // // Delete temp file // - di.close(); - compressOut.delete(); + //di.close(); + //compressOut.delete(); } catch (Exception e){