Display media sizes in international system units. Fixes #334

This commit is contained in:
2020-07-12 15:15:22 +01:00
parent d8d3d9cc88
commit 7659aebb28
7 changed files with 126 additions and 20 deletions

View File

@@ -214,8 +214,23 @@ namespace Aaru.Core.Devices.Dumping
{
blocks++;
UpdateStatus?.
Invoke($"Media has {blocks} blocks of {blockSize} bytes/each. (for a total of {blocks * (ulong)blockSize} bytes)");
ulong totalSize = blocks * blockSize;
if(totalSize > 1099511627776)
UpdateStatus?.
Invoke($"Media has {blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize / 1099511627776d:F3} TiB)");
else if(totalSize > 1073741824)
UpdateStatus?.
Invoke($"Media has {blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize / 1073741824d:F3} GiB)");
else if(totalSize > 1048576)
UpdateStatus?.
Invoke($"Media has {blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize / 1048576d:F3} MiB)");
else if(totalSize > 1024)
UpdateStatus?.
Invoke($"Media has {blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize / 1024d:F3} KiB)");
else
UpdateStatus?.
Invoke($"Media has {blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize} bytes)");
}
// Check how many blocks to read, if error show and return