diff --git a/BurnOutSharp.Wrappers/CFB.cs b/BurnOutSharp.Wrappers/CFB.cs index fd61e632..15a483f1 100644 --- a/BurnOutSharp.Wrappers/CFB.cs +++ b/BurnOutSharp.Wrappers/CFB.cs @@ -96,6 +96,20 @@ namespace BurnOutSharp.Wrappers #endregion + #region Extension Properties + + /// + /// Normal sector size in bytes + /// + public long SectorSize => (long)Math.Pow(2, SectorShift); + + /// + /// Mini sector size in bytes + /// + public long MiniSectorSize => (long)Math.Pow(2, MiniSectorShift); + + #endregion + #region Instance Variables /// @@ -215,8 +229,7 @@ namespace BurnOutSharp.Wrappers return null; // Try to read the sector data - int sectorDataLength = (int)Math.Pow(2, SectorShift); - var sectorData = ReadFromDataSource(sectorDataOffset, sectorDataLength); + var sectorData = ReadFromDataSource(sectorDataOffset, (int)SectorSize); if (sectorData == null) return null; @@ -239,7 +252,7 @@ namespace BurnOutSharp.Wrappers return -1; // Convert based on the sector shift value - return (long)((long)(sector + 1) * Math.Pow(2, SectorShift)); + return (long)(sector + 1) * SectorSize; } #endregion @@ -300,8 +313,7 @@ namespace BurnOutSharp.Wrappers return null; // Try to read the sector data - int sectorDataLength = (int)Math.Pow(2, MiniSectorShift); - var sectorData = ReadFromDataSource(sectorDataOffset, sectorDataLength); + var sectorData = ReadFromDataSource(sectorDataOffset, (int)MiniSectorSize); if (sectorData == null) return null; @@ -324,7 +336,7 @@ namespace BurnOutSharp.Wrappers return -1; // Convert based on the sector shift value - return (long)((long)(sector + 1) * Math.Pow(2, MiniSectorShift)); + return (long)(sector + 1) * MiniSectorSize; } #endregion