Ejemplo n.º 1
0
        public GZipProcessManager(string pathFromName, string pathToName, GZipOperation operation)
        {
            this.pathFrom      = pathFromName;
            this.pathTo        = pathToName;
            this.allWorkers    = new List <IWorker>();
            this.producerQueue = new BlockingQueue();

            if (operation == GZipOperation.Compress)
            {
                this.consumerCollection = new BlockingQueue();
                this.blockGZipper       = new BlockGZipCompressor();
                var fileReader = new SimpleFileFactory(pathFrom, BLOCK_SIZE).GetFileReader();
                this.blocksProducer = new BlocksProducer(fileReader,
                                                         this.producerQueue);
                this.blocksConsumer = new CompressBlocksConsumer(
                    new CompressedFileFactory(pathTo, fileReader.NumberOfBlocks).GetFileWriter(),
                    this.consumerCollection);
            }
            else
            {
                this.blockGZipper       = new BlockGZipDecompressor();
                this.consumerCollection = new BlockingDictionary();
                this.blocksProducer     = new BlocksProducer(
                    new CompressedFileFactory(pathFrom).GetFileReader(),
                    this.producerQueue);
                this.blocksConsumer = new DecompressBlocksConsumer(
                    new SimpleFileFactory(pathTo).GetFileWriter(),
                    this.consumerCollection);
            }

            this.End = new AutoResetEvent(false);
        }
Ejemplo n.º 2
0
        public void TestFileSimpleReader()
        {
            var debugPath     = Directory.GetCurrentDirectory();
            var binPath       = Path.GetDirectoryName(debugPath);
            var testsPath     = Path.GetDirectoryName(binPath);
            var countOfBlocks = 0;

            using (var reader = new SimpleFileFactory($@"{testsPath}/Rihter_CLR-via-C.pdf", 1024 * 1024).GetFileReader())
            {
                foreach (var block in reader)
                {
                    countOfBlocks++;
                }
                Assert.AreEqual(reader.NumberOfBlocks, countOfBlocks);
            }
        }