private void ReadChunk() { long size; byte[] properties; try { properties = SevenZipExtractor.GetLzmaProperties(_input, out size); } catch (Exception) { _error = true; return; } if (!_firstChunkRead) { _commonProperties = properties; } if (_commonProperties[0] != properties[0] || _commonProperties[1] != properties[1] || _commonProperties[2] != properties[2] || _commonProperties[3] != properties[3] || _commonProperties[4] != properties[4]) { _error = true; return; } #if ORIG if (_buffer.Capacity < (int)size) { _buffer.Capacity = (int)size; } _buffer.SetLength(size); #else // I MODIFIED THESE LINES FROM THE ORIGINAL. IT NOW USES A 32KB BUFFER FOR ALL CHUNK READS. // RATHER THAN THE 'outSize' FOR ME WAS ALWAYS RETURNING -1 AND HENCE SETLENGTH WOULD THROW // AN EXCEPTION. PAIR THIS STREAM WITH A SIMPLE COPYTO() OPERATION AND YOU HAVE A WORKING // STREAMED EXTRACTOR. _buffer.Capacity = 1024 * 32; _buffer.SetLength(_buffer.Capacity); #endif _decoder.SetDecoderProperties(properties); _buffer.Position = 0; _decoder.Code(_input, _buffer, 0, size, null); _buffer.Position = 0; }
private void ReadChunk() { long size; byte[] properties; try { properties = SevenZipExtractor.GetLzmaProperties(_input, out size); } catch (LzmaException) { _error = true; return; } if (!_firstChunkRead) { _commonProperties = properties; } if (_commonProperties[0] != properties[0] || _commonProperties[1] != properties[1] || _commonProperties[2] != properties[2] || _commonProperties[3] != properties[3] || _commonProperties[4] != properties[4]) { _error = true; return; } if (_buffer.Capacity < (int)size) { _buffer.Capacity = (int)size; } _buffer.SetLength(size); _decoder.SetDecoderProperties(properties); _buffer.Position = 0; _decoder.Code( _input, _buffer, 0, size, null); _buffer.Position = 0; }