Exemplo n.º 1
0
        internal int ExtendBitmapSpace()
        {
            var ix = TotalBitCount;

            TheStore.TheFile.Position = BitmapToPos(ix);
            TheStore.TheFile.WriteByte((byte)Store.SectorTypes.Unallocated);

            var next = new BitmapSector(TheStore, ix, SectorSize);

#if STORE_DETAILED_TRACE_LOGS
            System.Diagnostics.Debug.WriteLine("ExtendBitmapSpace: " + ix.ToString());
#endif

            // Its now reserving space for itself
            next[0] = true;

            var lastbitmapsector = TheStore.Bits;
            while (lastbitmapsector.NextBitmap != null)
            {
                lastbitmapsector = lastbitmapsector.NextBitmap;
            }
            lastbitmapsector.NextBitmap = next;
            TheStore.TheFile.Position   = BitmapToPos(lastbitmapsector.Ix) + 1;
            StreamUtils.WriteInt32(TheStore.TheFile, next.Ix);

            return(ix);
        }
Exemplo n.º 2
0
        private void InitializeBitmapSector()
        {
            TheStore.TheFile.Position = BitmapToPos(Ix);

            StreamUtils.WriteUInt8(TheStore.TheFile, (byte)Store.SectorTypes.Bitmap);
            StreamUtils.WriteInt32(TheStore.TheFile, Store.LAST_SECTOR_IN_CHAIN);
            NextBitmap = null;

            SectorData = new byte[(int)TheStore.SectorDataSize];
            StreamUtils.Write(TheStore.TheFile, SectorData);
        }
Exemplo n.º 3
0
        public static byte[] BCGZipCompress(byte[] buf)
        {
            using (var ms = new MemoryStream())
            {
                ms.WriteByte(0x1f);
                ms.WriteByte(0x8b);
                ms.WriteByte(0x08);
                ms.WriteByte(0x00);
                ms.WriteByte(0x00);
                ms.WriteByte(0x00);
                ms.WriteByte(0x00);
                ms.WriteByte(0x00);
                ms.WriteByte(0x02);
                ms.WriteByte(0xFF);

                using (var gzs = new ZOutputStream(ms, 6, true))
                {
                    gzs.Write(buf, 0, buf.Length);
                    gzs.Flush();
                }

                var crc = LZUtils.CRC32(buf);

                // ZOutputStream closes the outer stream...
                using (var ms2 = new MemoryStream())
                {
                    StreamUtils.Write(ms2, ms.ToArray());
                    StreamUtils.WriteUInt32(ms2, crc);
                    StreamUtils.WriteInt32(ms2, buf.Length);

                    var msb = ms2.ToArray();

                    /*
                     * using ( var foos = new FileStream( "test.gz", FileMode.Create, FileAccess.Write ) )
                     * {
                     * foos.Write( msb );
                     * }
                     */

                    return(msb);
                }
            }
        }