public static byte[] Decompress(CFLLoader.CompressionType compType, byte[] ins) { if (compType == CFLLoader.CompressionType.None) { return(ins); } var coder = new Decoder(); var input = new MemoryStream(ins); var output = new MemoryStream(); // Read the decoder properties var properties = new byte[5]; input.Read(properties, 0, 5); // Read in the decompress file size. var fileLengthBytes = new byte[8]; //input.Read(fileLengthBytes, 0, 8); long fileLength = -1; //BitConverter.ToInt64(fileLengthBytes, 0); coder.SetDecoderProperties(properties); coder.Code(input, output, input.Length, fileLength, null); output.Flush(); output.Position = 0; return(output.ToArray()); }
public void HeaderCompression(CFLLoader.CompressionType compression) { /* * if (compression == CFLLoader.CompressionType.LZMA) * throw new NotSupportedException(); */ _cFlHeader.Compression = compression; }
public void Add(string name, byte[] data, CFLLoader.CompressionType compression) { /* * if (compression == CFLLoader.CompressionType.LZMA) * throw new NotSupportedException(); */ var entry = new CFLEntry { Name = name, UnpackedSize = data.Length, Compression = compression, FileContents = data }; if (_cFlHeader.SupportsHash) { entry.Hash = Helpers.CalculateMD5Hash(data); } _entries.Add(entry); }