Start working on FAT formatter
This commit is contained in:
28
BadBuilder.Formatter/FAT32Utilities.cs
Normal file
28
BadBuilder.Formatter/FAT32Utilities.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace BadBuilder.Formatter
|
||||
{
|
||||
static class FAT32Utilities
|
||||
{
|
||||
internal static uint GetVolumeID()
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
|
||||
ushort low = (ushort)(now.Day + (now.Month << 8));
|
||||
low += (ushort)((now.Millisecond / 10) + (now.Second << 8));
|
||||
|
||||
ushort hi = (ushort)(now.Minute + (now.Hour << 8));
|
||||
hi += (ushort)now.Year;
|
||||
|
||||
return (uint)(low | (hi << 16));
|
||||
}
|
||||
|
||||
internal static uint CalculateFATSize(uint diskSize, uint reservedSectorCount, uint sectorsPerCluster, uint numberOfFATs, uint bytesPerSector)
|
||||
{
|
||||
const ulong fatElementSize = 4;
|
||||
|
||||
ulong numerator = fatElementSize * (diskSize - reservedSectorCount);
|
||||
ulong denominator = (sectorsPerCluster * bytesPerSector) + (fatElementSize * numberOfFATs);
|
||||
|
||||
return (uint)((numerator / denominator) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user