mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Display media sizes in international system units. Fixes #334
This commit is contained in:
@@ -114,8 +114,23 @@ namespace Aaru.Core.Devices.Dumping
|
|||||||
{
|
{
|
||||||
blocks++;
|
blocks++;
|
||||||
|
|
||||||
UpdateStatus?.
|
ulong totalSize = blocks * blockSize;
|
||||||
Invoke($"Media has {blocks} blocks of {blockSize} bytes/each. (for a total of {blocks * (ulong)blockSize} bytes)");
|
|
||||||
|
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
|
// Check how many blocks to read, if error show and return
|
||||||
|
|||||||
@@ -80,8 +80,23 @@ namespace Aaru.Core.Devices.Dumping
|
|||||||
|
|
||||||
blocks++;
|
blocks++;
|
||||||
|
|
||||||
UpdateStatus?.
|
ulong totalSize = blocks * (ulong)BLOCK_SIZE;
|
||||||
Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {blocks * (ulong)BLOCK_SIZE} bytes)");
|
|
||||||
|
if(totalSize > 1099511627776)
|
||||||
|
UpdateStatus?.
|
||||||
|
Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {totalSize / 1099511627776d:F3} TiB)");
|
||||||
|
else if(totalSize > 1073741824)
|
||||||
|
UpdateStatus?.
|
||||||
|
Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {totalSize / 1073741824d:F3} GiB)");
|
||||||
|
else if(totalSize > 1048576)
|
||||||
|
UpdateStatus?.
|
||||||
|
Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {totalSize / 1048576d:F3} MiB)");
|
||||||
|
else if(totalSize > 1024)
|
||||||
|
UpdateStatus?.
|
||||||
|
Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {totalSize / 1024d:F3} KiB)");
|
||||||
|
else
|
||||||
|
UpdateStatus?.
|
||||||
|
Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {totalSize} bytes)");
|
||||||
|
|
||||||
if(blocks == 0)
|
if(blocks == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -97,8 +97,23 @@ namespace Aaru.Core.Devices.Dumping
|
|||||||
ulong blocks = umdSizeInBytes / BLOCK_SIZE;
|
ulong blocks = umdSizeInBytes / BLOCK_SIZE;
|
||||||
string mediaPartNumber = Encoding.ASCII.GetString(readBuffer, 0, 11).Trim();
|
string mediaPartNumber = Encoding.ASCII.GetString(readBuffer, 0, 11).Trim();
|
||||||
|
|
||||||
UpdateStatus?.
|
ulong totalSize = blocks * BLOCK_SIZE;
|
||||||
Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {blocks * (ulong)BLOCK_SIZE} bytes)");
|
|
||||||
|
if(totalSize > 1099511627776)
|
||||||
|
UpdateStatus?.
|
||||||
|
Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {totalSize / 1099511627776d:F3} TiB)");
|
||||||
|
else if(totalSize > 1073741824)
|
||||||
|
UpdateStatus?.
|
||||||
|
Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {totalSize / 1073741824d:F3} GiB)");
|
||||||
|
else if(totalSize > 1048576)
|
||||||
|
UpdateStatus?.
|
||||||
|
Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {totalSize / 1048576d:F3} MiB)");
|
||||||
|
else if(totalSize > 1024)
|
||||||
|
UpdateStatus?.
|
||||||
|
Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {totalSize / 1024d:F3} KiB)");
|
||||||
|
else
|
||||||
|
UpdateStatus?.
|
||||||
|
Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {totalSize} bytes)");
|
||||||
|
|
||||||
UpdateStatus?.Invoke($"Device reports {blocks} blocks ({blocks * BLOCK_SIZE} bytes).");
|
UpdateStatus?.Invoke($"Device reports {blocks} blocks ({blocks * BLOCK_SIZE} bytes).");
|
||||||
UpdateStatus?.Invoke($"Device can read {blocksToRead} blocks at a time.");
|
UpdateStatus?.Invoke($"Device can read {blocksToRead} blocks at a time.");
|
||||||
|
|||||||
@@ -214,8 +214,23 @@ namespace Aaru.Core.Devices.Dumping
|
|||||||
{
|
{
|
||||||
blocks++;
|
blocks++;
|
||||||
|
|
||||||
UpdateStatus?.
|
ulong totalSize = blocks * blockSize;
|
||||||
Invoke($"Media has {blocks} blocks of {blockSize} bytes/each. (for a total of {blocks * (ulong)blockSize} bytes)");
|
|
||||||
|
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
|
// Check how many blocks to read, if error show and return
|
||||||
|
|||||||
@@ -186,8 +186,23 @@ namespace Aaru.Core.Devices.Scanning
|
|||||||
{
|
{
|
||||||
results.Blocks++;
|
results.Blocks++;
|
||||||
|
|
||||||
UpdateStatus?.
|
ulong totalSize = results.Blocks * blockSize;
|
||||||
Invoke($"Media has {results.Blocks} blocks of {blockSize} bytes/each. (for a total of {results.Blocks * (ulong)blockSize} bytes)");
|
|
||||||
|
if(totalSize > 1099511627776)
|
||||||
|
UpdateStatus?.
|
||||||
|
Invoke($"Media has {results.Blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize / 1099511627776d:F3} TiB)");
|
||||||
|
else if(totalSize > 1073741824)
|
||||||
|
UpdateStatus?.
|
||||||
|
Invoke($"Media has {results.Blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize / 1073741824d:F3} GiB)");
|
||||||
|
else if(totalSize > 1048576)
|
||||||
|
UpdateStatus?.
|
||||||
|
Invoke($"Media has {results.Blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize / 1048576d:F3} MiB)");
|
||||||
|
else if(totalSize > 1024)
|
||||||
|
UpdateStatus?.
|
||||||
|
Invoke($"Media has {results.Blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize / 1024d:F3} KiB)");
|
||||||
|
else
|
||||||
|
UpdateStatus?.
|
||||||
|
Invoke($"Media has {results.Blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize} bytes)");
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -432,8 +447,7 @@ namespace Aaru.Core.Devices.Scanning
|
|||||||
mhddLog.Close();
|
mhddLog.Close();
|
||||||
|
|
||||||
ibgLog.Close(_dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
|
ibgLog.Close(_dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
|
||||||
(blockSize * (double)(results.Blocks + 1)) / 1024 /
|
(blockSize * (double)(results.Blocks + 1)) / 1024 / (results.ProcessingTime / 1000),
|
||||||
(results.ProcessingTime / 1000),
|
|
||||||
_devicePath);
|
_devicePath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -526,8 +540,7 @@ namespace Aaru.Core.Devices.Scanning
|
|||||||
mhddLog.Close();
|
mhddLog.Close();
|
||||||
|
|
||||||
ibgLog.Close(_dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
|
ibgLog.Close(_dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
|
||||||
(blockSize * (double)(results.Blocks + 1)) / 1024 /
|
(blockSize * (double)(results.Blocks + 1)) / 1024 / (results.ProcessingTime / 1000),
|
||||||
(results.ProcessingTime / 1000),
|
|
||||||
_devicePath);
|
_devicePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,10 +101,27 @@ namespace Aaru.Gui.ViewModels.Panels
|
|||||||
|
|
||||||
MediaType = scsiInfo.MediaType.ToString();
|
MediaType = scsiInfo.MediaType.ToString();
|
||||||
|
|
||||||
if(scsiInfo.Blocks != 0 &&
|
if(scsiInfo.Blocks != 0 &&
|
||||||
scsiInfo.BlockSize != 0)
|
scsiInfo.BlockSize != 0)
|
||||||
MediaSize =
|
{
|
||||||
$"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize} bytes/each. (for a total of {scsiInfo.Blocks * scsiInfo.BlockSize} bytes)";
|
ulong totalSize = scsiInfo.Blocks * scsiInfo.BlockSize;
|
||||||
|
|
||||||
|
if(totalSize > 1099511627776)
|
||||||
|
MediaSize =
|
||||||
|
$"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize} bytes/each. (for a total of {totalSize / 1099511627776d:F3} TiB)";
|
||||||
|
else if(totalSize > 1073741824)
|
||||||
|
MediaSize =
|
||||||
|
$"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize} bytes/each. (for a total of {totalSize / 1073741824d:F3} GiB)";
|
||||||
|
else if(totalSize > 1048576)
|
||||||
|
MediaSize =
|
||||||
|
$"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize} bytes/each. (for a total of {totalSize / 1048576d:F3} MiB)";
|
||||||
|
else if(totalSize > 1024)
|
||||||
|
MediaSize =
|
||||||
|
$"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize} bytes/each. (for a total of {totalSize / 1024d:F3} KiB)";
|
||||||
|
else
|
||||||
|
MediaSize =
|
||||||
|
$"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize} bytes/each. (for a total of {totalSize} bytes)";
|
||||||
|
}
|
||||||
|
|
||||||
if(scsiInfo.MediaSerialNumber != null)
|
if(scsiInfo.MediaSerialNumber != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -199,9 +199,25 @@ namespace Aaru.Commands.Media
|
|||||||
|
|
||||||
if(scsiInfo.Blocks != 0 &&
|
if(scsiInfo.Blocks != 0 &&
|
||||||
scsiInfo.BlockSize != 0)
|
scsiInfo.BlockSize != 0)
|
||||||
AaruConsole.WriteLine("Media has {0} blocks of {1} bytes/each. (for a total of {2} bytes)",
|
{
|
||||||
scsiInfo.Blocks, scsiInfo.BlockSize,
|
ulong totalSize = scsiInfo.Blocks * scsiInfo.BlockSize;
|
||||||
scsiInfo.Blocks * scsiInfo.BlockSize);
|
|
||||||
|
if(totalSize > 1099511627776)
|
||||||
|
AaruConsole.WriteLine("Media has {0} blocks of {1} bytes/each. (for a total of {2:F3} TiB)",
|
||||||
|
scsiInfo.Blocks, scsiInfo.BlockSize, totalSize / 1099511627776d);
|
||||||
|
else if(totalSize > 1073741824)
|
||||||
|
AaruConsole.WriteLine("Media has {0} blocks of {1} bytes/each. (for a total of {2:F3} GiB)",
|
||||||
|
scsiInfo.Blocks, scsiInfo.BlockSize, totalSize / 1073741824d);
|
||||||
|
else if(totalSize > 1048576)
|
||||||
|
AaruConsole.WriteLine("Media has {0} blocks of {1} bytes/each. (for a total of {2:F3} MiB)",
|
||||||
|
scsiInfo.Blocks, scsiInfo.BlockSize, totalSize / 1048576d);
|
||||||
|
else if(totalSize > 1024)
|
||||||
|
AaruConsole.WriteLine("Media has {0} blocks of {1} bytes/each. (for a total of {2:F3} KiB)",
|
||||||
|
scsiInfo.Blocks, scsiInfo.BlockSize, totalSize / 1024d);
|
||||||
|
else
|
||||||
|
AaruConsole.WriteLine("Media has {0} blocks of {1} bytes/each. (for a total of {2} bytes)",
|
||||||
|
scsiInfo.Blocks, scsiInfo.BlockSize, totalSize);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case PeripheralDeviceTypes.SequentialAccess:
|
case PeripheralDeviceTypes.SequentialAccess:
|
||||||
|
|||||||
Reference in New Issue
Block a user