123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace DiskAccessLibrary.LogicalDiskManager
- {
- public class PublicRegionHelper
- {
-
-
-
-
- public const int BytesPerPublicRegionSector = 512;
- public static long TranslateFromPublicRegionLBA(long publicRegionOffsetLBA, long publicRegionStartLBA, int bytesPerDiskSector)
- {
- return publicRegionStartLBA + publicRegionOffsetLBA * BytesPerPublicRegionSector / bytesPerDiskSector;
- }
- public static long TranslateFromPublicRegionSizeLBA(long sectorCount, int bytesPerDiskSector)
- {
- return sectorCount * BytesPerPublicRegionSector / bytesPerDiskSector;
- }
- public static long TranslateToPublicRegionLBA(long sectorIndex, PrivateHeader privateHeader)
- {
- return TranslateToPublicRegionLBA(sectorIndex, (long)privateHeader.PublicRegionStartLBA, (int)privateHeader.BytesPerSector);
- }
- public static long TranslateToPublicRegionLBA(long sectorIndex, long publicRegionStartLBA, int bytesPerDiskSector)
- {
- return (sectorIndex - publicRegionStartLBA) * bytesPerDiskSector / BytesPerPublicRegionSector;
- }
- public static long TranslateToPublicRegionSizeLBA(long sectorCount, PrivateHeader privateHeader)
- {
- return TranslateToPublicRegionSizeLBA(sectorCount, (int)privateHeader.BytesPerSector);
- }
- public static long TranslateToPublicRegionSizeLBA(long sectorCount, int bytesPerDiskSector)
- {
- return sectorCount * bytesPerDiskSector / BytesPerPublicRegionSector;
- }
- }
- }
|