Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
 public void HeaderCompression(CFLLoader.CompressionType compression)
 {
     /*
      * if (compression == CFLLoader.CompressionType.LZMA)
      *  throw new NotSupportedException();
      */
     _cFlHeader.Compression = compression;
 }
Exemplo n.º 3
0
        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);
        }