Ejemplo n.º 1
0
        [Test] public void ZipBlob()
        {
            MemoryStream         sourceStream     = new MemoryStream(new byte[] { 12, 34, 56, 78 });
            MemoryStream         compressedStream = new MemoryStream();
            DeflaterOutputStream deflaterStream   = new DeflaterOutputStream(compressedStream);

            StreamUtils.Copy(sourceStream, deflaterStream, new byte[4096]);
            deflaterStream.Finish();
            compressedStream.Capacity = (int)compressedStream.Length;
            StructInstance instance = PrepareInstance(
                "struct A { blob q [len=FileSize, encoding=zlib]; }",
                compressedStream.GetBuffer());
            BlobCell cell = (BlobCell)instance.Cells[0];

            Assert.AreEqual(4, cell.DataStream.Length);
        }
Ejemplo n.º 2
0
        private void SaveBlobCell(BlobCell blobCell, string name)
        {
            string outName = Path.Combine(_outDir, name);

            Directory.CreateDirectory(Path.GetDirectoryName(outName));
            Stream ms = blobCell.DataStream;

            using (var fs = new FileStream(outName, FileMode.CreateNew))
            {
                while (true)
                {
                    int bytes = ms.Read(_buffer, 0, 64000);
                    if (bytes == 0)
                    {
                        break;
                    }
                    fs.Write(_buffer, 0, bytes);
                }
            }
        }
Ejemplo n.º 3
0
 public BlobCellUI(BlobCell cell)
 {
     _cell = cell;
 }