Beispiel #1
0
        internal long Persist()
        {
            if (_fragmentBlocks.Count <= 0)
            {
                return(-1);
            }

            if (_fragmentBlocks.Count * FragmentRecord.RecordSize > _context.DataBlockSize)
            {
                throw new NotImplementedException("Large numbers of fragments");
            }

            // Persist the table that references the block containing the fragment records
            long blockPos   = _context.RawStream.Position;
            int  recordSize = FragmentRecord.RecordSize;

            byte[] buffer = new byte[_fragmentBlocks.Count * recordSize];
            for (int i = 0; i < _fragmentBlocks.Count; ++i)
            {
                _fragmentBlocks[i].WriteTo(buffer, i * recordSize);
            }

            MetablockWriter writer = new MetablockWriter();

            writer.Write(buffer, 0, buffer.Length);
            writer.Persist(_context.RawStream);

            long tablePos = _context.RawStream.Position;

            byte[] tableBuffer = new byte[8];
            Utilities.WriteBytesLittleEndian(blockPos, tableBuffer, 0);
            _context.RawStream.Write(tableBuffer, 0, 8);

            return(tablePos);
        }
Beispiel #2
0
        internal long Persist()
        {
            if (_ids.Count <= 0)
            {
                return(-1);
            }

            if (_ids.Count * 4 > _context.DataBlockSize)
            {
                throw new NotImplementedException("Large numbers of user / group id's");
            }

            for (int i = 0; i < _ids.Count; ++i)
            {
                Utilities.WriteBytesLittleEndian(_ids[i], _context.IoBuffer, i * 4);
            }

            // Persist the actual Id's
            long            blockPos = _context.RawStream.Position;
            MetablockWriter writer   = new MetablockWriter();

            writer.Write(_context.IoBuffer, 0, _ids.Count * 4);
            writer.Persist(_context.RawStream);

            // Persist the table that references the block containing the id's
            long tablePos = _context.RawStream.Position;

            byte[] tableBuffer = new byte[8];
            Utilities.WriteBytesLittleEndian(blockPos, tableBuffer, 0);
            _context.RawStream.Write(tableBuffer, 0, 8);

            return(tablePos);
        }
Beispiel #3
0
        internal long Persist()
        {
            if (_ids.Count <= 0)
            {
                return -1;
            }

            if (_ids.Count * 4 > _context.DataBlockSize)
            {
                throw new NotImplementedException("Large numbers of user / group id's");
            }

            for (int i = 0; i < _ids.Count; ++i)
            {
                Utilities.WriteBytesLittleEndian(_ids[i], _context.IoBuffer, i * 4);
            }

            // Persist the actual Id's
            long blockPos = _context.RawStream.Position;
            MetablockWriter writer = new MetablockWriter();
            writer.Write(_context.IoBuffer, 0, _ids.Count * 4);
            writer.Persist(_context.RawStream);

            // Persist the table that references the block containing the id's
            long tablePos = _context.RawStream.Position;
            byte[] tableBuffer = new byte[8];
            Utilities.WriteBytesLittleEndian(blockPos, tableBuffer, 0);
            _context.RawStream.Write(tableBuffer, 0, 8);

            return tablePos;
        }
Beispiel #4
0
        internal long Persist()
        {
            if (_fragmentBlocks.Count <= 0)
            {
                return -1;
            }

            if (_fragmentBlocks.Count * FragmentRecord.RecordSize > _context.DataBlockSize)
            {
                throw new NotImplementedException("Large numbers of fragments");
            }

            // Persist the table that references the block containing the fragment records
            long blockPos = _context.RawStream.Position;
            int recordSize = FragmentRecord.RecordSize;
            byte[] buffer = new byte[_fragmentBlocks.Count * recordSize];
            for (int i = 0; i < _fragmentBlocks.Count; ++i)
            {
                _fragmentBlocks[i].WriteTo(buffer, i * recordSize);
            }

            MetablockWriter writer = new MetablockWriter();
            writer.Write(buffer, 0, buffer.Length);
            writer.Persist(_context.RawStream);

            long tablePos = _context.RawStream.Position;
            byte[] tableBuffer = new byte[8];
            Utilities.WriteBytesLittleEndian(blockPos, tableBuffer, 0);
            _context.RawStream.Write(tableBuffer, 0, 8);

            return tablePos;
        }