Beispiel #1
0
        static void Main(string[] args)
        {
            Console.CancelKeyPress += (sender, ceArgs) =>
            {
                StatusManager.ProcessIsCanceled = true;
                ConsoleLogger.WriteDiagnosticInfo(PROCESS_CANCELLED);
                Environment.Exit(FAILURE_EXIT_CODE);
            };

            try
            {
                Validation.CheckInputParameters(args);
                var inputFile = new FileInfo(args[1]);

                var threadManager = new ThreadManager();

                FileReader        fileReader    = null;
                FileWriter        fileWriter    = null;
                Archiever         archiever     = null;
                OperationType     operationType = OperationType.Compress;
                GZipBlockArchiver compressor    = new GZipBlockArchiver(args[1], args[2], threadManager, inputFile.Length);

                if (args[0] == Dictionary.COMPRESS_COMMAND)
                {
                    fileReader = new UncompressedFileReader(args[1], compressor.CompressedDataManagers);
                    fileWriter = new CompressedFileWriter(args[2], compressor.DictionaryWritingManager);
                    archiever  = new Compressor(compressor.CompressedDataManagers, compressor.DictionaryWritingManager);
                }
                else
                {
                    fileReader    = new CompressedFileReader(args[1], compressor.CompressedDataManagers);
                    fileWriter    = new DecompressedFileWriter(args[2], compressor.DictionaryWritingManager);
                    archiever     = new Decompressor(compressor.CompressedDataManagers, compressor.DictionaryWritingManager);
                    operationType = OperationType.Decompress;
                }

                var processResult = compressor.Start(fileReader, archiever, fileWriter, operationType);

                Console.CursorTop += 1;
                if (processResult && !StatusManager.ProcessIsCanceled)
                {
                    ConsoleLogger.WriteSuccessInfo($"{args[2]} : {SUCCESS_CREATED}");
                }
                else
                {
                    ConsoleLogger.WriteError($"{args[2]}: {FAILURE_CREATED}");
                }
            }
            catch (Exception ex)
            {
                ConsoleLogger.WriteError(FAILURE_CREATED);
                Console.WriteLine(END_PROCESS);
                Console.ReadKey();
            }
        }
Beispiel #2
0
Datei: LZ77.cs Projekt: okkt/jn18
 public void Decompress(string path)
 {
     reader     = new CompressedFileReader(path);
     bitBuffer  = new List <bool>();
     charBuffer = new StringBuilder();
     dictionary = new StringBuilder();
     phrase     = string.Empty;
     using (var streamWriter = new StreamWriter(path.Replace(".lz", string.Empty)))
     {
         while (reader.CanReadBlock)
         {
             var bits = reader.ReadBlock();
             decompressBlock(bits, streamWriter);
         }
     }
     reader.Close();
 }
Beispiel #3
0
        public void Decompress(string input, string output, int decompressedClunkSize)
        {
            var chunksPool = new DataChunksPool();

            using (var readStream = new FileStream(input, FileMode.Open))
                using (var writeStream = new FileStream(output, FileMode.Create))
                {
                    var reader = new CompressedFileReader(readStream, chunksPool.Get);
                    var writer = new OrderedWriter(writeStream, new PlainFormatter(), 10, chunksPool.Return);

                    var worker = new Worker(
                        reader,
                        writer,
                        new DataChunkDecompressProcessor(decompressedClunkSize, chunksPool.Get),
                        chunksPool.Return);
                    worker.Process();
                }
        }