GetOctalBytes() публичный статический Метод

Put an octal representation of a value into a buffer
public static GetOctalBytes ( long value, byte buffer, int offset, int length ) : int
value long /// the value to be converted to octal ///
buffer byte /// buffer to store the octal string ///
offset int /// The offset into the buffer where the value starts ///
length int /// The length of the octal string to create ///
Результат int
Пример #1
0
        /// <summary>
        /// Add the checksum octal integer to header buffer.
        /// </summary>
        /// <param name = "val">
        /// </param>
        /// <param name = "buf">
        /// The header buffer to set the checksum for
        /// </param>
        /// <param name = "offset">
        /// The offset into the buffer for the checksum
        /// </param>
        /// <param name = "length">
        /// 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

        /// </param>
        /// <returns>
        /// The modified buffer offset
        /// </returns>
        private static int GetCheckSumOctalBytes(long val, byte[] buf, int offset, int length)
        {
            TarHeader.GetOctalBytes(val, buf, offset, length - 1);
//			buf[offset + length - 1] = (byte)' ';  -jr- 23-Jan-2004 this causes failure!!!
//			buf[offset + length - 2] = 0;
            return(offset + length);
        }
Пример #2
0
 private static int GetBinaryOrOctalBytes(long value, byte[] buffer, int offset, int length)
 {
     if (value > 8589934591L)
     {
         for (int i = length - 1; i > 0; i--)
         {
             buffer[offset + i] = (byte)value;
             value >>= 8;
         }
         buffer[offset] = 128;
         return(offset + length);
     }
     return(TarHeader.GetOctalBytes(value, buffer, offset, length));
 }
Пример #3
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;
        }
Пример #4
0
 /// <summary>
 /// Add the checksum integer to header buffer.
 /// </summary>
 /// <param name = "value"></param>
 /// <param name = "buffer">The header buffer to set the checksum for</param>
 /// <param name = "offset">The offset into the buffer for the checksum</param>
 /// <param name = "length">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
 /// </param>
 /// <returns>The modified buffer offset</returns>
 static int GetCheckSumOctalBytes(long value, byte[] buffer, int offset, int length)
 {
     TarHeader.GetOctalBytes(value, buffer, offset, length - 1);
     return(offset + length);
 }
Пример #5
0
 public static int GetLongOctalBytes(long value, byte[] buffer, int offset, int length)
 {
     return(TarHeader.GetOctalBytes(value, buffer, offset, length));
 }
Пример #6
0
 private static void GetCheckSumOctalBytes(long value, byte[] buffer, int offset, int length)
 {
     TarHeader.GetOctalBytes(value, buffer, offset, length - 1);
 }