Partition.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* Copyright (C) 2014-2016 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 DiskExtent Extent
  47. {
  48. get
  49. {
  50. return m_extent;
  51. }
  52. }
  53. public override List<DiskExtent> Extents
  54. {
  55. get
  56. {
  57. List<DiskExtent> result = new List<DiskExtent>();
  58. result.Add(m_extent);
  59. return result;
  60. }
  61. }
  62. public Disk Disk
  63. {
  64. get
  65. {
  66. return m_extent.Disk;
  67. }
  68. }
  69. public long FirstSector
  70. {
  71. get
  72. {
  73. return m_extent.FirstSector;
  74. }
  75. }
  76. }
  77. }