mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Use Humanizer to print bytes.
This commit is contained in:
@@ -47,6 +47,7 @@ using Aaru.Core.Graphics;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Devices;
|
||||
using Humanizer.Bytes;
|
||||
using Version = Aaru.CommonTypes.Interop.Version;
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
@@ -121,41 +122,9 @@ partial class Dump
|
||||
{
|
||||
blocks++;
|
||||
|
||||
ulong totalSize = blocks * blockSize;
|
||||
|
||||
switch(totalSize)
|
||||
{
|
||||
case > 1099511627776:
|
||||
UpdateStatus?.
|
||||
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_TiB,
|
||||
blocks, blockSize, totalSize / 1099511627776d));
|
||||
|
||||
break;
|
||||
case > 1073741824:
|
||||
UpdateStatus?.
|
||||
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_GiB,
|
||||
blocks, blockSize, totalSize / 1073741824d));
|
||||
|
||||
break;
|
||||
case > 1048576:
|
||||
UpdateStatus?.
|
||||
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_MiB,
|
||||
blocks, blockSize, totalSize / 1048576d));
|
||||
|
||||
break;
|
||||
case > 1024:
|
||||
UpdateStatus?.
|
||||
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_KiB,
|
||||
blocks, blockSize, totalSize / 1024d));
|
||||
|
||||
break;
|
||||
default:
|
||||
UpdateStatus?.
|
||||
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_bytes,
|
||||
blocks, blockSize, totalSize));
|
||||
|
||||
break;
|
||||
}
|
||||
UpdateStatus?.Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2,
|
||||
blocks, blockSize,
|
||||
ByteSize.FromBytes(blocks * blockSize).ToString("0.000")));
|
||||
}
|
||||
|
||||
// Check how many blocks to read, if error show and return
|
||||
|
||||
@@ -47,6 +47,7 @@ using Aaru.Core.Graphics;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Devices;
|
||||
using Humanizer.Bytes;
|
||||
using Version = Aaru.CommonTypes.Interop.Version;
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
@@ -90,41 +91,9 @@ public partial class Dump
|
||||
|
||||
blocks++;
|
||||
|
||||
ulong totalSize = blocks * (ulong)blockSize;
|
||||
|
||||
switch(totalSize)
|
||||
{
|
||||
case > 1099511627776:
|
||||
UpdateStatus?.
|
||||
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_TiB,
|
||||
blocks, blockSize, totalSize / 1099511627776d));
|
||||
|
||||
break;
|
||||
case > 1073741824:
|
||||
UpdateStatus?.
|
||||
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_GiB,
|
||||
blocks, blockSize, totalSize / 1073741824d));
|
||||
|
||||
break;
|
||||
case > 1048576:
|
||||
UpdateStatus?.
|
||||
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_MiB,
|
||||
blocks, blockSize, totalSize / 1048576d));
|
||||
|
||||
break;
|
||||
case > 1024:
|
||||
UpdateStatus?.
|
||||
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_KiB,
|
||||
blocks, blockSize, totalSize / 1024d));
|
||||
|
||||
break;
|
||||
default:
|
||||
UpdateStatus?.
|
||||
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_bytes,
|
||||
blocks, blockSize, totalSize));
|
||||
|
||||
break;
|
||||
}
|
||||
UpdateStatus?.Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2,
|
||||
blocks, blockSize,
|
||||
ByteSize.FromBytes(blocks * blockSize).ToString("0.000")));
|
||||
|
||||
if(blocks == 0)
|
||||
{
|
||||
|
||||
@@ -45,6 +45,7 @@ using Aaru.Core.Graphics;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Devices;
|
||||
using Humanizer.Bytes;
|
||||
using Track = Aaru.CommonTypes.Structs.Track;
|
||||
using TrackType = Aaru.CommonTypes.Enums.TrackType;
|
||||
using Version = Aaru.CommonTypes.Interop.Version;
|
||||
@@ -109,35 +110,9 @@ public partial class Dump
|
||||
ulong blocks = umdSizeInBytes / blockSize;
|
||||
string mediaPartNumber = Encoding.ASCII.GetString(readBuffer, 0, 11).Trim();
|
||||
|
||||
ulong totalSize = blocks * blockSize;
|
||||
|
||||
switch(totalSize)
|
||||
{
|
||||
case > 1073741824:
|
||||
UpdateStatus?.
|
||||
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_GiB,
|
||||
blocks, blockSize, totalSize / 1073741824d));
|
||||
|
||||
break;
|
||||
case > 1048576:
|
||||
UpdateStatus?.
|
||||
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_MiB,
|
||||
blocks, blockSize, totalSize / 1048576d));
|
||||
|
||||
break;
|
||||
case > 1024:
|
||||
UpdateStatus?.
|
||||
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_KiB,
|
||||
blocks, blockSize, totalSize / 1024d));
|
||||
|
||||
break;
|
||||
default:
|
||||
UpdateStatus?.
|
||||
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_bytes,
|
||||
blocks, blockSize, totalSize));
|
||||
|
||||
break;
|
||||
}
|
||||
UpdateStatus?.Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2,
|
||||
blocks, blockSize,
|
||||
ByteSize.FromBytes(blocks * blockSize).ToString("0.000")));
|
||||
|
||||
UpdateStatus?.Invoke(string.Format(Localization.Core.Device_reports_0_blocks_1_bytes, blocks,
|
||||
blocks * blockSize));
|
||||
|
||||
@@ -52,6 +52,7 @@ using Aaru.Decoders.DVD;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Decoders.SCSI.MMC;
|
||||
using Aaru.Devices;
|
||||
using Humanizer.Bytes;
|
||||
using DVDDecryption = Aaru.Decryption.DVD.Dump;
|
||||
using Track = Aaru.CommonTypes.Structs.Track;
|
||||
using TrackType = Aaru.CommonTypes.Enums.TrackType;
|
||||
@@ -223,41 +224,9 @@ partial class Dump
|
||||
{
|
||||
blocks++;
|
||||
|
||||
ulong totalSize = blocks * blockSize;
|
||||
|
||||
switch(totalSize)
|
||||
{
|
||||
case > 1099511627776:
|
||||
UpdateStatus?.
|
||||
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_TiB,
|
||||
blocks, blockSize, totalSize / 1099511627776d));
|
||||
|
||||
break;
|
||||
case > 1073741824:
|
||||
UpdateStatus?.
|
||||
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_GiB,
|
||||
blocks, blockSize, totalSize / 1073741824d));
|
||||
|
||||
break;
|
||||
case > 1048576:
|
||||
UpdateStatus?.
|
||||
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_MiB,
|
||||
blocks, blockSize, totalSize / 1048576d));
|
||||
|
||||
break;
|
||||
case > 1024:
|
||||
UpdateStatus?.
|
||||
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_KiB,
|
||||
blocks, blockSize, totalSize / 1024d));
|
||||
|
||||
break;
|
||||
default:
|
||||
UpdateStatus?.
|
||||
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_bytes,
|
||||
blocks, blockSize, totalSize));
|
||||
|
||||
break;
|
||||
}
|
||||
UpdateStatus?.Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2,
|
||||
blocks, blockSize,
|
||||
ByteSize.FromBytes(blocks * blockSize).ToString("0.000")));
|
||||
}
|
||||
|
||||
// Check how many blocks to read, if error show and return
|
||||
|
||||
@@ -40,6 +40,7 @@ using Aaru.Decoders.CD;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Decoders.SCSI.MMC;
|
||||
using Aaru.Devices;
|
||||
using Humanizer.Bytes;
|
||||
|
||||
namespace Aaru.Core.Devices.Scanning;
|
||||
|
||||
@@ -199,46 +200,10 @@ public sealed partial class MediaScan
|
||||
{
|
||||
results.Blocks++;
|
||||
|
||||
ulong totalSize = results.Blocks * blockSize;
|
||||
|
||||
switch(totalSize)
|
||||
{
|
||||
case > 1099511627776:
|
||||
UpdateStatus?.
|
||||
Invoke(string.
|
||||
Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_TiB,
|
||||
results.Blocks, blockSize, totalSize / 1099511627776d));
|
||||
|
||||
break;
|
||||
case > 1073741824:
|
||||
UpdateStatus?.
|
||||
Invoke(string.
|
||||
Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_GiB,
|
||||
results.Blocks, blockSize, totalSize / 1073741824d));
|
||||
|
||||
break;
|
||||
case > 1048576:
|
||||
UpdateStatus?.
|
||||
Invoke(string.
|
||||
Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_MiB,
|
||||
results.Blocks, blockSize, totalSize / 1048576d));
|
||||
|
||||
break;
|
||||
case > 1024:
|
||||
UpdateStatus?.
|
||||
Invoke(string.
|
||||
Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_KiB,
|
||||
results.Blocks, blockSize, totalSize / 1024d));
|
||||
|
||||
break;
|
||||
default:
|
||||
UpdateStatus?.
|
||||
Invoke(string.
|
||||
Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2_bytes,
|
||||
results.Blocks, blockSize, totalSize));
|
||||
|
||||
break;
|
||||
}
|
||||
UpdateStatus?.
|
||||
Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2,
|
||||
results.Blocks, blockSize,
|
||||
ByteSize.FromBytes(results.Blocks * blockSize).ToString("0.000")));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user