diff --git a/SrcMod/Shell/Modules/CompressionModule.cs b/SrcMod/Shell/Modules/CompressionModule.cs index e1e87fa..043e653 100644 --- a/SrcMod/Shell/Modules/CompressionModule.cs +++ b/SrcMod/Shell/Modules/CompressionModule.cs @@ -32,27 +32,14 @@ public static class CompressionModule reader = new(absSource, FileMode.Open); GZipStream gzip = new(writer, level); - LoadingBarStart(); - - int bufferSize = Mathf.Clamp((int)reader.Length / Console.BufferWidth, 1024 * 1024, 128 * 1024 * 1024); - byte[] buffer = new byte[bufferSize]; - for (long i = 0; i < reader.Length; i += bufferSize) - { - int size = reader.Read(buffer, 0, bufferSize); - gzip.Write(buffer, 0, size); - gzip.Flush(); - - LoadingBarSet((float)i / reader.Length, ConsoleColor.DarkGreen); - } - - LoadingBarEnd(); + reader.CopyTo(gzip); gzip.Close(); reader.Close(); writer.Close(); Console.CursorLeft = 0; - Console.CursorTop -= (message.Length / Console.BufferWidth) + 2; + Console.CursorTop -= (message.Length / Console.BufferWidth) + 1; Write(new string(' ', message.Length), newLine: false); } else if (Directory.Exists(source)) throw new("The GZip format can only compress 1 file."); diff --git a/SrcMod/Shell/Modules/ExtractionModule.cs b/SrcMod/Shell/Modules/ExtractionModule.cs index e06d826..a7d8bc7 100644 --- a/SrcMod/Shell/Modules/ExtractionModule.cs +++ b/SrcMod/Shell/Modules/ExtractionModule.cs @@ -29,21 +29,7 @@ public static class ExtractionModule reader = new(absSource, FileMode.Open); GZipStream gzip = new(reader, CompressionMode.Decompress); - LoadingBarStart(); - - int bufferSize = Mathf.Clamp((int)reader.Length / Console.BufferWidth, 1024 * 1024, 128 * 1024 * 1024); - byte[] buffer = new byte[bufferSize]; - int i = 0; - int size; - while ((size = gzip.Read(buffer, i, bufferSize)) > 0) - { - writer.Write(buffer, 0, size); - writer.Flush(); - - LoadingBarSet((float)i / reader.Length, ConsoleColor.DarkGreen); - } - - LoadingBarEnd(); + gzip.CopyTo(writer); gzip.Close(); reader.Close(); @@ -51,7 +37,6 @@ public static class ExtractionModule Console.CursorLeft = 0; Console.CursorTop -= (message.Length / Console.BufferWidth) + 1; - if (Console.CursorTop >= Console.BufferHeight - 3) Console.CursorTop--; Write(new string(' ', message.Length), newLine: false); }