/// <summary> /// Creates a new instance of this class. /// </summary> /// <param name="ioSessions">IoSessions to use to read from this disk</param> public IndexParser(SubFileDiskIoSessionPool ioSessions) : base(ioSessions.Header.BlockSize) { m_subFile = ioSessions.File; m_ioSessions = ioSessions; m_oldFirstOffset = -1; }
/// <summary> /// Releases the unmanaged resources used by the <see cref="IoSession"/> object and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { if (!m_disposed) { try { // This will be done regardless of whether the object is finalized or disposed. if (disposing) { if (m_ioSessions != null) { m_ioSessions.Dispose(); m_ioSessions = null; } // This will be done only when the object is disposed by calling Dispose(). } } finally { m_parser = null; m_pager = null; m_disposed = true; // Prevent duplicate dispose. base.Dispose(disposing); // Call base class Dispose(). } } }
/// <summary> /// Creates a <see cref="ShadowCopyAllocator"/> that is used make shadow copies of blocks. /// </summary> /// <param name="ioSessions"></param> public ShadowCopyAllocator(SubFileDiskIoSessionPool ioSessions) : base(ioSessions) { if (ioSessions == null) throw new ArgumentNullException("ioSessions"); if (ioSessions.IsReadOnly) throw new ArgumentException("DataReader is read only", "ioSessions"); m_lastReadOnlyBlock = ioSessions.LastReadonlyBlock; m_fileHeaderBlock = ioSessions.Header; m_subFileHeader = ioSessions.File; m_ioSessions = ioSessions; }
/// <summary> /// Creates a <see cref="ShadowCopyAllocator"/> that is used make shadow copies of blocks. /// </summary> /// <param name="ioSessions"></param> public ShadowCopyAllocator(SubFileDiskIoSessionPool ioSessions) : base(ioSessions) { if (ioSessions == null) { throw new ArgumentNullException("ioSessions"); } if (ioSessions.IsReadOnly) { throw new ArgumentException("DataReader is read only", "ioSessions"); } m_lastReadOnlyBlock = ioSessions.LastReadonlyBlock; m_fileHeaderBlock = ioSessions.Header; m_subFileHeader = ioSessions.File; m_ioSessions = ioSessions; }
public IoSession(SubFileStream stream) { m_stream = stream; m_lastEditedBlock = stream.m_dataReader.LastCommittedHeader.LastAllocatedBlock; m_isReadOnly = stream.m_isReadOnly; m_blockDataLength = m_stream.m_blockSize - FileStructureConstants.BlockFooterLength; m_ioSessions = new SubFileDiskIoSessionPool(stream.m_dataReader, stream.m_fileHeaderBlock, stream.m_subFile, stream.m_isReadOnly); if (m_isReadOnly) { m_parser = new IndexParser(m_ioSessions); } else { m_pager = new ShadowCopyAllocator(m_ioSessions); m_parser = m_pager; } }