Example #1
0
        public static void Main(string[] args)
        {
            Options options = new Options();
            CommandLine.Parser.Default.ParseArguments(args, options);

            if(options.IsCompress == options.IsDecompress || string.IsNullOrEmpty(options.InputFileName) || string.IsNullOrEmpty(options.OutputFileName))
            {
                Console.WriteLine(0);
                return;
            }

            Program program = new Program();
            Console.CancelKeyPress += program.Handler;

            program.RunConsole(options);
        }
Example #2
0
        private void RunConsole(Options options)
        {
            try
            {
                inputStream = GetInputStream(options.InputFileName);
                outputStream = GetOutputStream(options.OutputFileName);
            }
            catch(FileNotFoundException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(0);
                return;
            }
            catch(FileLoadException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(0);
                return;
            }

            this.baseProcessor = null;
            if(options.IsCompress)
            {
                this.baseProcessor = new CompressionProcessor(inputStream, outputStream, options.Blocksize, options.HashType);
            }
            else
            {
                this.baseProcessor = new DecompressionProcessor(inputStream, outputStream);
            }

            var result = this.baseProcessor.Run();
            Console.WriteLine(result ? 1 : 0);

            this.DisposeStreams();
        }