diff --git a/Aaru.Core/Devices/Dumping/MiniDisc.cs b/Aaru.Core/Devices/Dumping/MiniDisc.cs index 40318f038..fd65ac609 100644 --- a/Aaru.Core/Devices/Dumping/MiniDisc.cs +++ b/Aaru.Core/Devices/Dumping/MiniDisc.cs @@ -114,8 +114,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 diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs index a9123257b..fbdc040d1 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs @@ -80,8 +80,23 @@ namespace Aaru.Core.Devices.Dumping blocks++; - UpdateStatus?. - Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {blocks * (ulong)BLOCK_SIZE} bytes)"); + ulong totalSize = blocks * (ulong)BLOCK_SIZE; + + 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) { diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs index d7dd68e19..b69657ed3 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs @@ -97,8 +97,23 @@ namespace Aaru.Core.Devices.Dumping ulong blocks = umdSizeInBytes / BLOCK_SIZE; string mediaPartNumber = Encoding.ASCII.GetString(readBuffer, 0, 11).Trim(); - UpdateStatus?. - Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {blocks * (ulong)BLOCK_SIZE} bytes)"); + ulong totalSize = blocks * BLOCK_SIZE; + + 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 can read {blocksToRead} blocks at a time."); diff --git a/Aaru.Core/Devices/Dumping/SBC.cs b/Aaru.Core/Devices/Dumping/SBC.cs index e790706f9..bbffe8323 100644 --- a/Aaru.Core/Devices/Dumping/SBC.cs +++ b/Aaru.Core/Devices/Dumping/SBC.cs @@ -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 diff --git a/Aaru.Core/Devices/Scanning/SCSI.cs b/Aaru.Core/Devices/Scanning/SCSI.cs index f0097024b..20c983be6 100644 --- a/Aaru.Core/Devices/Scanning/SCSI.cs +++ b/Aaru.Core/Devices/Scanning/SCSI.cs @@ -186,8 +186,23 @@ namespace Aaru.Core.Devices.Scanning { results.Blocks++; - UpdateStatus?. - Invoke($"Media has {results.Blocks} blocks of {blockSize} bytes/each. (for a total of {results.Blocks * (ulong)blockSize} bytes)"); + ulong totalSize = results.Blocks * blockSize; + + 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; @@ -432,8 +447,7 @@ namespace Aaru.Core.Devices.Scanning mhddLog.Close(); ibgLog.Close(_dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, - (blockSize * (double)(results.Blocks + 1)) / 1024 / - (results.ProcessingTime / 1000), + (blockSize * (double)(results.Blocks + 1)) / 1024 / (results.ProcessingTime / 1000), _devicePath); } else @@ -526,8 +540,7 @@ namespace Aaru.Core.Devices.Scanning mhddLog.Close(); ibgLog.Close(_dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, - (blockSize * (double)(results.Blocks + 1)) / 1024 / - (results.ProcessingTime / 1000), + (blockSize * (double)(results.Blocks + 1)) / 1024 / (results.ProcessingTime / 1000), _devicePath); } diff --git a/Aaru.Gui/ViewModels/Panels/MediaInfoViewModel.cs b/Aaru.Gui/ViewModels/Panels/MediaInfoViewModel.cs index 580f43a4c..93fa01ce5 100644 --- a/Aaru.Gui/ViewModels/Panels/MediaInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/MediaInfoViewModel.cs @@ -101,10 +101,27 @@ namespace Aaru.Gui.ViewModels.Panels MediaType = scsiInfo.MediaType.ToString(); - if(scsiInfo.Blocks != 0 && + if(scsiInfo.Blocks != 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) { diff --git a/Aaru/Commands/Media/Info.cs b/Aaru/Commands/Media/Info.cs index fa8382a5b..8b79598c4 100644 --- a/Aaru/Commands/Media/Info.cs +++ b/Aaru/Commands/Media/Info.cs @@ -199,9 +199,25 @@ namespace Aaru.Commands.Media if(scsiInfo.Blocks != 0 && scsiInfo.BlockSize != 0) - AaruConsole.WriteLine("Media has {0} blocks of {1} bytes/each. (for a total of {2} bytes)", - scsiInfo.Blocks, scsiInfo.BlockSize, - scsiInfo.Blocks * scsiInfo.BlockSize); + { + ulong totalSize = 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; case PeripheralDeviceTypes.SequentialAccess: