static void Decompress(string[] args) { if (args.Length < 3) { Help(); return; } BrotliCompression.Decompress(args[1], args[2]); }
static void Compress(string[] args) { if (args.Length < 2) { Help(); return; } string outPath = args.Length == 2 ? args[1] + ".compressed" : args[2]; BrotliCompression.Compress(args[1], outPath); }
static void RunTests() { Directory.CreateDirectory("data"); // uncompress all test data foreach (string file in Directory.EnumerateFiles(@"..\..\..\..\tests\testdata", "*.compressed")) { string uncompressed = Path.Combine("data", Path.GetFileNameWithoutExtension(file)); Console.WriteLine(Path.GetFileName(file) + " -> decompress -> " + uncompressed); BrotliCompression.Decompress(file, uncompressed); } // recompress all foreach (string file in Directory.EnumerateFiles(@"data")) { if (Path.GetExtension(file).ToLowerInvariant() == ".compressed") { continue; } string recompressed = file + ".compressed"; Console.WriteLine(file + " -> compress -> " + recompressed); BrotliCompression.Compress(file, recompressed); } // decompress all again foreach (string file in Directory.GetFiles(@"data")) { if (Path.GetExtension(file).ToLowerInvariant() != ".compressed") { continue; } string uncompressed = Path.Combine("data", Path.GetFileNameWithoutExtension(file)); Console.WriteLine(file + " -> redecompress -> " + uncompressed); BrotliCompression.Decompress(file, uncompressed); } }