예제 #1
0
 public static void WriteToFile(Header header, BinaryWriter writer)
 {
     writer.BaseStream.Seek(0L, SeekOrigin.Begin);
     writer.Write("FileDB".ToBytes("FileDB".Length));
     writer.Write((short) 1);
     writer.Write(header.IndexRootPageID);
     writer.Write(header.FreeIndexPageID);
     writer.Write(header.FreeDataPageID);
     writer.Write(header.LastFreeDataPageID);
     writer.Write(header.LastPageID);
 }
예제 #2
0
 public static void ReadFromFile(Header header, BinaryReader reader)
 {
     reader.BaseStream.Seek(0L, SeekOrigin.Begin);
     if (reader.ReadString("FileDB".Length) != "FileDB")
     {
         throw new FileDBException("The file is not a valid storage archive");
     }
     if (reader.ReadInt16() != 1)
     {
         throw new FileDBException("The archive version is not valid");
     }
     header.IndexRootPageID = reader.ReadUInt32();
     header.FreeIndexPageID = reader.ReadUInt32();
     header.FreeDataPageID = reader.ReadUInt32();
     header.LastFreeDataPageID = reader.ReadUInt32();
     header.LastPageID = reader.ReadUInt32();
     header.IsDirty = false;
 }
예제 #3
0
파일: FileFactory.cs 프로젝트: mind0n/hive
 public static void CreateEmptyFile(BinaryWriter writer)
 {
     Header header = new Header {
         IndexRootPageID = 0,
         FreeIndexPageID = 0,
         FreeDataPageID = uint.MaxValue,
         LastFreeDataPageID = uint.MaxValue,
         LastPageID = 0
     };
     HeaderFactory.WriteToFile(header, writer);
     IndexUnit pageIndex = new IndexUnit(0) {
         NodeIndex = 0,
         NextUnitID = uint.MaxValue
     };
     IndexNode indexNode = pageIndex.Nodes[0];
     indexNode.ID = new Guid(new byte[] { 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f });
     indexNode.IsDeleted = true;
     indexNode.Right = new IndexLink();
     indexNode.Left = new IndexLink();
     indexNode.DataPageID = uint.MaxValue;
     indexNode.FileName = string.Empty;
     indexNode.FileExtension = string.Empty;
     UnitFactory.WriteToFile(pageIndex, writer);
 }