Skip to content

Commit

Permalink
Added file savings output to console
Browse files Browse the repository at this point in the history
  • Loading branch information
deanhume committed Sep 9, 2024
1 parent e48f044 commit 66eedcb
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions ViewMinifier/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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));
Expand All @@ -46,7 +45,6 @@ static void Main(string[] args)
Console.WriteLine("------------------------------------------");

}
Console.Read();
}

/// <summary>
Expand Down Expand Up @@ -126,14 +124,24 @@ public static string MinifyHtml(string filePath, Features features)
}
}

static String BytesToString(long byteCount)
/// <summary>
/// Converts bytes to a human readable string.
/// </summary>
/// <param name="byteCount">bytes</param>
/// <returns>A human readable string</returns>
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];
}
}
Expand Down

0 comments on commit 66eedcb

Please sign in to comment.