mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 21:47:21 +01:00
potential mcdf fixes
This commit is contained in:
parent
1ae6f4ec54
commit
0edd21a8e1
4 changed files with 62 additions and 24 deletions
|
|
@ -10,6 +10,32 @@ namespace MareSynchronos.Utils;
|
|||
|
||||
public static class VariousExtensions
|
||||
{
|
||||
public static string ToByteString(this int bytes, bool addSuffix = true)
|
||||
{
|
||||
string[] suffix = ["B", "KiB", "MiB", "GiB", "TiB"];
|
||||
int i;
|
||||
double dblSByte = bytes;
|
||||
for (i = 0; i < suffix.Length && bytes >= 1024; i++, bytes /= 1024)
|
||||
{
|
||||
dblSByte = bytes / 1024.0;
|
||||
}
|
||||
|
||||
return addSuffix ? $"{dblSByte:0.00} {suffix[i]}" : $"{dblSByte:0.00}";
|
||||
}
|
||||
|
||||
public static string ToByteString(this long bytes, bool addSuffix = true)
|
||||
{
|
||||
string[] suffix = ["B", "KiB", "MiB", "GiB", "TiB"];
|
||||
int i;
|
||||
double dblSByte = bytes;
|
||||
for (i = 0; i < suffix.Length && bytes >= 1024; i++, bytes /= 1024)
|
||||
{
|
||||
dblSByte = bytes / 1024.0;
|
||||
}
|
||||
|
||||
return addSuffix ? $"{dblSByte:0.00} {suffix[i]}" : $"{dblSByte:0.00}";
|
||||
}
|
||||
|
||||
public static void CancelDispose(this CancellationTokenSource? cts)
|
||||
{
|
||||
try
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue