Partition.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. using Utilities;
  11. namespace DiskAccessLibrary
  12. {
  13. public abstract class Partition : Volume
  14. {
  15. private DiskExtent m_extent;
  16. public Partition(DiskExtent extent)
  17. {
  18. m_extent = extent;
  19. }
  20. public Partition(Disk disk, long firstSector, long size)
  21. {
  22. m_extent = new DiskExtent(disk, firstSector, size);
  23. }
  24. public override byte[] ReadSectors(long sectorIndex, int sectorCount)
  25. {
  26. return m_extent.ReadSectors(sectorIndex, sectorCount);
  27. }
  28. public override void WriteSectors(long sectorIndex, byte[] data)
  29. {
  30. m_extent.WriteSectors(sectorIndex, data);
  31. }
  32. public override int BytesPerSector
  33. {
  34. get
  35. {
  36. return m_extent.BytesPerSector;
  37. }
  38. }
  39. public override long Size
  40. {
  41. get
  42. {
  43. return m_extent.Size;
  44. }
  45. }
  46. public override List<DiskExtent> Extents
  47. {
  48. get
  49. {
  50. List<DiskExtent> result = new List<DiskExtent>();
  51. result.Add(m_extent);
  52. return result;
  53. }
  54. }
  55. public Disk Disk
  56. {
  57. get
  58. {
  59. return m_extent.Disk;
  60. }
  61. }
  62. public long FirstSector
  63. {
  64. get
  65. {
  66. return m_extent.FirstSector;
  67. }
  68. }
  69. }
  70. }