Disk.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* Copyright (C) 2014 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  2. *
  3. * You can redistribute this program and/or modify it under the terms of
  4. * the GNU Lesser Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. public abstract class Disk
  11. {
  12. private bool m_isReadOnly = false;
  13. /// <summary>
  14. /// Sector refers to physical disk sector
  15. /// </summary>
  16. public abstract byte[] ReadSectors(long sectorIndex, int sectorCount);
  17. public abstract void WriteSectors(long sectorIndex, byte[] data);
  18. public byte[] ReadSector(long sectorIndex)
  19. {
  20. return ReadSectors(sectorIndex, 1);
  21. }
  22. public bool IsReadOnly
  23. {
  24. get
  25. {
  26. return m_isReadOnly;
  27. }
  28. set
  29. {
  30. m_isReadOnly = value;
  31. }
  32. }
  33. public abstract int BytesPerSector
  34. {
  35. get;
  36. }
  37. public abstract long Size
  38. {
  39. get;
  40. }
  41. public long TotalSectors
  42. {
  43. get
  44. {
  45. return this.Size / this.BytesPerSector;
  46. }
  47. }
  48. }