private FileHeader m_fileHeader; //the only file header in the two files, it is located at page 0. public memSegmentManager(DiskFile file) { m_cache = new CacheHashtable(m_cacheSize); m_pageSize = 1 << m_pageBits; m_diskFile = file; m_bitmap = new PageBitmap(); m_fileHeader = new FileHeader(); if (file.Length < m_bitmap.Data.Length + m_pageSize * 2) //page 0 for fileheader, page 33 for segTree, page 44 for spacetree { //this helper file is a new one for (int i = 0; i < (m_bitmap.Data.Length >> (m_pageBits + 3)); i++) { m_bitmap.Data[i] = 0xFF; } m_bitmap.SetPageTaken(m_bitmap.GetFirstFreePageID()); //one more page taken because of the fileheader m_bitmap.Dirty = true; m_fileHeader.SetInitializeNeeded(); } else { byte[] header = file.SynRead(0, m_pageSize); m_fileHeader.Deserialize(header); file.SynRead(m_bitmap.Data, 0, m_pageSize, m_bitmap.Data.Length); } m_LRU = new BNode(); }
private FileHeader m_fileHeader; //the only file header in the two files, it is located at page 0. public memSegmentManager(DiskFile file) { m_cache = new CacheHashtable(m_cacheSize); m_pageSize = 1 << m_pageBits; m_diskFile = file; m_bitmap = new PageBitmap(); m_fileHeader = new FileHeader(); if (file.Length < m_bitmap.Data.Length + m_pageSize*2) //page 0 for fileheader, page 33 for segTree, page 44 for spacetree { //this helper file is a new one for (int i=0; i<(m_bitmap.Data.Length >> (m_pageBits + 3)); i++) m_bitmap.Data[i] = 0xFF; m_bitmap.SetPageTaken(m_bitmap.GetFirstFreePageID()); //one more page taken because of the fileheader m_bitmap.Dirty = true; m_fileHeader.SetInitializeNeeded(); } else { byte[] header = file.SynRead(0, m_pageSize); m_fileHeader.Deserialize(header); file.SynRead(m_bitmap.Data, 0, m_pageSize, m_bitmap.Data.Length); } m_LRU = new BNode(); }