Skip to content

Commit

Permalink
larger & file calc
Browse files Browse the repository at this point in the history
  • Loading branch information
Anime4000 committed Jun 7, 2020
1 parent 469e197 commit 0cea0f6
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 23 deletions.
28 changes: 28 additions & 0 deletions IFME.OSManager/OS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,33 @@ public static void PowerOff(int delay = 0)
else if (IsLinux)
Process.Start("bash", "-c 'poweroff'");
}

public static string PrintFileSize(ulong value)
{
if (IsWindows)
{
string[] IEC = { "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB" };

if (value == 0)
return $"0{IEC[0]}";

long bytes = Math.Abs((long)value);
int place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024)));
double num = Math.Round(bytes / Math.Pow(1024, place), 1);
return $"{(Math.Sign((long)value) * num)} {IEC[place]}";
}
else
{
string[] DEC = { "B", "KB", "MB", "GB", "TB", "PB", "EB" };

if (value == 0)
return $"0{DEC[0]}";

long bytes = Math.Abs((long)value);
int place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1000)));
double num = Math.Round(bytes / Math.Pow(1000, place), 1);
return $"{(Math.Sign((long)value) * num)} {DEC[place]}";
}
}
}
}
44 changes: 22 additions & 22 deletions IFME/frmMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion IFME/frmMain.Function.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private void MediaFileListAdd(string path)
Path.GetFileName(path),
Path.GetExtension(path).Substring(1).ToUpperInvariant(),
TimeSpan.FromSeconds(fileData.Duration).ToString("hh\\:mm\\:ss"),
$"{fileData.FileSize}",
OS.PrintFileSize(fileData.FileSize),
fileQueue.Enable ? "Ready" : "Done",
""
})
Expand Down
1 change: 1 addition & 0 deletions IFME/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ private void lstFile_SelectedIndexChanged(object sender, EventArgs e)
lstAudio.Items.Clear();
lstSub.Items.Clear();
lstAttach.Items.Clear();
txtMediaInfo.Text = "FFmpeg Media Info ♥";
}

// Check queue consistency
Expand Down
Loading

0 comments on commit 0cea0f6

Please sign in to comment.