From 66eedcbc2059721c66ab169b9a7bf82de8c894e3 Mon Sep 17 00:00:00 2001 From: Dean Date: Mon, 9 Sep 2024 16:37:22 +0100 Subject: [PATCH] Added file savings output to console --- ViewMinifier/Program.cs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ViewMinifier/Program.cs b/ViewMinifier/Program.cs index 3c93a61..a0408b0 100644 --- a/ViewMinifier/Program.cs +++ b/ViewMinifier/Program.cs @@ -16,9 +16,6 @@ public class Program static void Main(string[] args) { - args = new string[1]; - args[0] = @"c:\temp\test"; - if (args.Length == 0) { Console.WriteLine("Please provide folder path or file(s) to process"); @@ -38,6 +35,8 @@ static void Main(string[] args) ProcessFile(features, arg); } } + + // Write the results Console.WriteLine("Minification Complete"); Console.WriteLine("------------------------------------------"); Console.WriteLine("Total Processed: {0}", BytesToString(totalProcessed)); @@ -46,7 +45,6 @@ static void Main(string[] args) Console.WriteLine("------------------------------------------"); } - Console.Read(); } /// @@ -126,14 +124,24 @@ public static string MinifyHtml(string filePath, Features features) } } - static String BytesToString(long byteCount) + /// + /// Converts bytes to a human readable string. + /// + /// bytes + /// A human readable string + private static string BytesToString(long byteCount) { - string[] suf = { "B", "KB", "MB", "GB", "TB", "PB", "EB" }; //Longs run out around EB + string[] suf = { "B", "KB", "MB", "GB", "TB", "PB", "EB" }; + if (byteCount == 0) return "0" + suf[0]; + long bytes = Math.Abs(byteCount); + int place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024))); + double num = Math.Round(bytes / Math.Pow(1024, place), 1); + return (Math.Sign(byteCount) * num).ToString() + suf[place]; } }