1baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// OutBuffer.cs 2baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 3baa3858d3f5d128a5c8466b700098109edcad5f2repo syncnamespace SevenZip.Buffer 4baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 5baa3858d3f5d128a5c8466b700098109edcad5f2repo sync public class OutBuffer 6baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 7baa3858d3f5d128a5c8466b700098109edcad5f2repo sync byte[] m_Buffer; 8baa3858d3f5d128a5c8466b700098109edcad5f2repo sync uint m_Pos; 9baa3858d3f5d128a5c8466b700098109edcad5f2repo sync uint m_BufferSize; 10baa3858d3f5d128a5c8466b700098109edcad5f2repo sync System.IO.Stream m_Stream; 11baa3858d3f5d128a5c8466b700098109edcad5f2repo sync ulong m_ProcessedSize; 12baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 13baa3858d3f5d128a5c8466b700098109edcad5f2repo sync public OutBuffer(uint bufferSize) 14baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 15baa3858d3f5d128a5c8466b700098109edcad5f2repo sync m_Buffer = new byte[bufferSize]; 16baa3858d3f5d128a5c8466b700098109edcad5f2repo sync m_BufferSize = bufferSize; 17baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 18baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 19baa3858d3f5d128a5c8466b700098109edcad5f2repo sync public void SetStream(System.IO.Stream stream) { m_Stream = stream; } 20baa3858d3f5d128a5c8466b700098109edcad5f2repo sync public void FlushStream() { m_Stream.Flush(); } 21baa3858d3f5d128a5c8466b700098109edcad5f2repo sync public void CloseStream() { m_Stream.Close(); } 22baa3858d3f5d128a5c8466b700098109edcad5f2repo sync public void ReleaseStream() { m_Stream = null; } 23baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 24baa3858d3f5d128a5c8466b700098109edcad5f2repo sync public void Init() 25baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 26baa3858d3f5d128a5c8466b700098109edcad5f2repo sync m_ProcessedSize = 0; 27baa3858d3f5d128a5c8466b700098109edcad5f2repo sync m_Pos = 0; 28baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 29baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 30baa3858d3f5d128a5c8466b700098109edcad5f2repo sync public void WriteByte(byte b) 31baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 32baa3858d3f5d128a5c8466b700098109edcad5f2repo sync m_Buffer[m_Pos++] = b; 33baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if (m_Pos >= m_BufferSize) 34baa3858d3f5d128a5c8466b700098109edcad5f2repo sync FlushData(); 35baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 36baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 37baa3858d3f5d128a5c8466b700098109edcad5f2repo sync public void FlushData() 38baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 39baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if (m_Pos == 0) 40baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return; 41baa3858d3f5d128a5c8466b700098109edcad5f2repo sync m_Stream.Write(m_Buffer, 0, (int)m_Pos); 42baa3858d3f5d128a5c8466b700098109edcad5f2repo sync m_Pos = 0; 43baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 44baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 45baa3858d3f5d128a5c8466b700098109edcad5f2repo sync public ulong GetProcessedSize() { return m_ProcessedSize + m_Pos; } 46baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 47baa3858d3f5d128a5c8466b700098109edcad5f2repo sync} 48