/* Copyright (C) 2014 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, * either version 3 of the License, or (at your option) any later version. */ using System; using System.Collections.Generic; using System.Text; public abstract class Volume { /// /// Sector refers to physical disk sector, we can only read complete sectors /// public abstract byte[] ReadSectors(long sectorIndex, int sectorCount); public abstract void WriteSectors(long sectorIndex, byte[] data); public byte[] ReadSector(long sectorIndex) { return ReadSectors(sectorIndex, 1); } public void CheckBoundaries(long sectorIndex, int sectorCount) { if (sectorIndex < 0 || sectorIndex + sectorCount - 1 >= this.TotalSectors) { throw new ArgumentOutOfRangeException("Attempted to access data outside of volume"); } } public abstract int BytesPerSector { get; } public abstract long Size { get; } public abstract List Extents { get; } public long TotalSectors { get { return this.Size / this.BytesPerSector; } } }