Project Maintenance

This commit is contained in:
Gustave Monce
2021-08-09 20:21:09 +02:00
parent 9865ef7f79
commit 847ce0506d
411 changed files with 5922 additions and 54941 deletions
+21 -9
View File
@@ -4,13 +4,13 @@ namespace SevenZip.Buffer
{
public class InBuffer
{
byte[] m_Buffer;
uint m_Pos;
uint m_Limit;
uint m_BufferSize;
System.IO.Stream m_Stream;
bool m_StreamWasExhausted;
ulong m_ProcessedSize;
private readonly byte[] m_Buffer;
private uint m_Pos;
private uint m_Limit;
private readonly uint m_BufferSize;
private System.IO.Stream m_Stream;
private bool m_StreamWasExhausted;
private ulong m_ProcessedSize;
public InBuffer(uint bufferSize)
{
@@ -30,16 +30,18 @@ namespace SevenZip.Buffer
public bool ReadBlock()
{
if (m_StreamWasExhausted)
{
return false;
}
m_ProcessedSize += m_Pos;
int aNumProcessedBytes = m_Stream.Read(m_Buffer, 0, (int)m_BufferSize);
m_Pos = 0;
m_Limit = (uint)aNumProcessedBytes;
m_StreamWasExhausted = (aNumProcessedBytes == 0);
return (!m_StreamWasExhausted);
return !m_StreamWasExhausted;
}
public void ReleaseStream()
{
// m_Stream.Close();
@@ -49,8 +51,13 @@ namespace SevenZip.Buffer
public bool ReadByte(byte b) // check it
{
if (m_Pos >= m_Limit)
{
if (!ReadBlock())
{
return false;
}
}
b = m_Buffer[m_Pos++];
return true;
}
@@ -59,8 +66,13 @@ namespace SevenZip.Buffer
{
// return (byte)m_Stream.ReadByte();
if (m_Pos >= m_Limit)
{
if (!ReadBlock())
{
return 0xFF;
}
}
return m_Buffer[m_Pos++];
}