Exemple #1
0
        private void UpdateToc()
        {
            //Open buffer for all objects
            byte[]           objectTocBuffer = new byte[TOC_ENTRY_LENGTH * objects.Count];
            BufferBinaryTool writer          = new BufferBinaryTool(objectTocBuffer);

            //Add all
            for (int i = 0; i < objects.Count; i += 1)
            {
                int offset = TOC_ENTRY_LENGTH * i;
                writer.WriteUInt64(offset + 0, objects[i].object_id);
                writer.WriteUInt64(offset + 8, objects[i].page_id);
                writer.WriteUInt64(offset + 16, objects[i].commit_id);
                writer.WriteInt32(offset + 24, objects[i].group_id);
                objectTocBuffer[offset + 28] = objects[i].commit_type;
                objectTocBuffer[offset + 29] = objects[i].flags;
                writer.WriteUInt16(offset + 30, objects[i].reserved);
            }

            //Add or update
            if (tocPage == -1)
            {
                tocPage = file.WriteNewBlob(PAGE_TYPE_TOC, objectTocBuffer);
            }
            else
            {
                tocPage = file.UpdateBlob(tocPage, PAGE_TYPE_TOC, objectTocBuffer);
            }
        }