GetCheckSumOctalBytes() static private method

Add the checksum integer to header buffer.
static private GetCheckSumOctalBytes ( long value, byte buffer, int offset, int length ) : void
value long
buffer byte The header buffer to set the checksum for
offset int The offset into the buffer for the checksum
length int The number of header bytes to update. /// It's formatted differently from the other fields: it has 6 digits, a /// null, then a space -- rather than digits, a space, then a null. /// The final space is already there, from checksumming ///
return void
Exemplo n.º 1
0
        public void WriteHeader(byte[] outBuffer)
        {
            if (outBuffer == null)
            {
                throw new ArgumentNullException("outBuffer");
            }
            int i = 0;

            i = TarHeader.GetNameBytes(this.Name, outBuffer, i, 100);
            i = TarHeader.GetOctalBytes((long)this.mode, outBuffer, i, 8);
            i = TarHeader.GetOctalBytes((long)this.UserId, outBuffer, i, 8);
            i = TarHeader.GetOctalBytes((long)this.GroupId, outBuffer, i, 8);
            long value = this.Size;

            i = TarHeader.GetLongOctalBytes(value, outBuffer, i, 12);
            i = TarHeader.GetLongOctalBytes((long)TarHeader.GetCTime(this.ModTime), outBuffer, i, 12);
            int offset = i;

            for (int j = 0; j < 8; j++)
            {
                outBuffer[i++] = 32;
            }
            outBuffer[i++] = this.TypeFlag;
            i = TarHeader.GetNameBytes(this.LinkName, outBuffer, i, 100);
            i = TarHeader.GetAsciiBytes(this.Magic, 0, outBuffer, i, 6);
            i = TarHeader.GetNameBytes(this.Version, outBuffer, i, 2);
            i = TarHeader.GetNameBytes(this.UserName, outBuffer, i, 32);
            i = TarHeader.GetNameBytes(this.GroupName, outBuffer, i, 32);
            if (this.TypeFlag == 51 || this.TypeFlag == 52)
            {
                i = TarHeader.GetOctalBytes((long)this.DevMajor, outBuffer, i, 8);
                i = TarHeader.GetOctalBytes((long)this.DevMinor, outBuffer, i, 8);
            }
            while (i < outBuffer.Length)
            {
                outBuffer[i++] = 0;
            }
            this.checksum = TarHeader.ComputeCheckSum(outBuffer);
            TarHeader.GetCheckSumOctalBytes((long)this.checksum, outBuffer, offset, 8);
            this.isChecksumValid = true;
        }