ReadBlock() public method

Read a block from the input stream.
public ReadBlock ( ) : byte[]
return byte[]
Example #1
0
        public override int Read(byte[] buffer, int offset, int count)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }
            int num = 0;

            if (entryOffset >= entrySize)
            {
                return(0);
            }
            long num2 = count;

            if (num2 + entryOffset > entrySize)
            {
                num2 = entrySize - entryOffset;
            }
            if (readBuffer != null)
            {
                int num3 = (int)((num2 > readBuffer.Length) ? readBuffer.Length : num2);
                Array.Copy(readBuffer, 0, buffer, offset, num3);
                if (num3 >= readBuffer.Length)
                {
                    readBuffer = null;
                }
                else
                {
                    int    num4             = readBuffer.Length - num3;
                    byte[] destinationArray = new byte[num4];
                    Array.Copy(readBuffer, num3, destinationArray, 0, num4);
                    readBuffer = destinationArray;
                }
                num    += num3;
                num2   -= num3;
                offset += num3;
            }
            while (num2 > 0)
            {
                byte[] array = tarBuffer.ReadBlock();
                if (array == null)
                {
                    throw new TarException("unexpected EOF with " + num2 + " bytes unread");
                }
                int num5 = (int)num2;
                int num6 = array.Length;
                if (num6 > num5)
                {
                    Array.Copy(array, 0, buffer, offset, num5);
                    readBuffer = new byte[num6 - num5];
                    Array.Copy(array, num5, readBuffer, 0, num6 - num5);
                }
                else
                {
                    num5 = num6;
                    Array.Copy(array, 0, buffer, offset, num6);
                }
                num    += num5;
                num2   -= num5;
                offset += num5;
            }
            entryOffset += num;
            return(num);
        }
Example #2
0
        public override int Read(byte[] buffer, int offset, int count)
        {
            //IL_0008: Unknown result type (might be due to invalid IL or missing references)
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }
            int num = 0;

            if (entryOffset >= entrySize)
            {
                return(0);
            }
            long num2 = count;

            if (num2 + entryOffset > entrySize)
            {
                num2 = entrySize - entryOffset;
            }
            if (readBuffer != null)
            {
                int num3 = (int)((num2 > readBuffer.Length) ? readBuffer.Length : num2);
                global::System.Array.Copy((global::System.Array)readBuffer, 0, (global::System.Array)buffer, offset, num3);
                if (num3 >= readBuffer.Length)
                {
                    readBuffer = null;
                }
                else
                {
                    int    num4  = readBuffer.Length - num3;
                    byte[] array = new byte[num4];
                    global::System.Array.Copy((global::System.Array)readBuffer, num3, (global::System.Array)array, 0, num4);
                    readBuffer = array;
                }
                num    += num3;
                num2   -= num3;
                offset += num3;
            }
            while (num2 > 0)
            {
                byte[] array2 = tarBuffer.ReadBlock();
                if (array2 == null)
                {
                    throw new TarException(string.Concat((object)"unexpected EOF with ", (object)num2, (object)" bytes unread"));
                }
                int num5 = (int)num2;
                int num6 = array2.Length;
                if (num6 > num5)
                {
                    global::System.Array.Copy((global::System.Array)array2, 0, (global::System.Array)buffer, offset, num5);
                    readBuffer = new byte[num6 - num5];
                    global::System.Array.Copy((global::System.Array)array2, num5, (global::System.Array)readBuffer, 0, num6 - num5);
                }
                else
                {
                    num5 = num6;
                    global::System.Array.Copy((global::System.Array)array2, 0, (global::System.Array)buffer, offset, num6);
                }
                num    += num5;
                num2   -= num5;
                offset += num5;
            }
            entryOffset += num;
            return(num);
        }