public BrZipArchiveEntry(BrZipReadArchive archive, string name, long offset, long compressedLength, long length) { if (archive == null) { throw new ArgumentNullException(nameof(archive)); } if (name == null) { throw new ArgumentNullException(nameof(name)); } Archive = archive; Name = name; Offset = offset; CompressedLength = compressedLength; Length = length; }
static void SafeMain(string[] args) { Console.WriteLine("BrZip - Copyright (C) 2018-" + DateTime.Now.Year + " Simon Mourier. All rights reserved."); Console.WriteLine(); if (CommandLine.HelpRequested || args.Length < 2) { Help(); return; } var arg = CommandLine.GetNullifiedArgument(0); if (!Conversions.TryChangeType <CompressionMode>(arg, out var mode)) { Help(); return; } var inputPath = CommandLine.GetNullifiedArgument(1); if (inputPath == null) { Help(); return; } inputPath = Path.GetFullPath(inputPath); Console.WriteLine("Input path: " + inputPath); var outputPath = CommandLine.GetNullifiedArgument(2); if (mode == CompressionMode.Decompress) { bool lo = CommandLine.GetArgument("listonly", false); outputPath = Path.GetFullPath(outputPath ?? Path.GetFileNameWithoutExtension(inputPath)); Console.WriteLine("Output path: " + outputPath); using (var readArchive = new BrZipReadArchive()) { readArchive.Open(inputPath); Console.WriteLine("Archive has " + readArchive.Entries.Count + " entrie(s)."); if (lo) { foreach (var entry in readArchive.Entries) { Console.WriteLine(entry.Value.Name); } return; } foreach (var entry in readArchive.Entries) { var path = Path.Combine(outputPath, entry.Value.Name); entry.Value.WriteAsync(path).Wait(); Console.WriteLine("Written " + entry.Value.Name + " to " + path); } } return; } outputPath = Path.GetFullPath(outputPath ?? Path.GetFileNameWithoutExtension(inputPath) + Extension); Console.WriteLine("Output path: " + outputPath); using (var writeArchive = new BrZipWriteArchive()) { writeArchive.AddedEntry += OnAddedEntry; writeArchive.Open(outputPath); if (File.Exists(inputPath)) { writeArchive.AddEntry(inputPath); return; } writeArchive.AddDirectory(inputPath); } return; }