private bool FmtBuf(byte[] nameBuf, int namePos, int nameLen, FileMode mode) { if (buf == null || buf.Length < ptr + EntrySize(mode, nameLen)) { return(false); } mode.CopyTo(buf, ptr); ptr += mode.CopyToLength(); buf[ptr++] = (byte)(' '); System.Array.Copy(nameBuf, namePos, buf, ptr, nameLen); ptr += nameLen; buf[ptr++] = 0; return(true); }
/// <summary>Compute the size of a tree entry record.</summary> /// <remarks> /// Compute the size of a tree entry record. /// This method can be used to estimate the correct size of a tree prior to /// allocating a formatter. Getting the size correct at allocation time /// ensures the internal buffer is sized correctly, reducing copying. /// </remarks> /// <param name="mode">the mode the entry will have.</param> /// <param name="nameLen">the length of the name, in bytes.</param> /// <returns>the length of the record.</returns> public static int EntrySize(FileMode mode, int nameLen) { return(mode.CopyToLength() + nameLen + Constants.OBJECT_ID_LENGTH + 2); }
/// <summary>Compute the size of a tree entry record.</summary> /// <remarks> /// Compute the size of a tree entry record. /// This method can be used to estimate the correct size of a tree prior to /// allocating a formatter. Getting the size correct at allocation time /// ensures the internal buffer is sized correctly, reducing copying. /// </remarks> /// <param name="mode">the mode the entry will have.</param> /// <param name="nameLen">the length of the name, in bytes.</param> /// <returns>the length of the record.</returns> public static int EntrySize(FileMode mode, int nameLen) { return mode.CopyToLength() + nameLen + Constants.OBJECT_ID_LENGTH + 2; }
private bool FmtBuf(byte[] nameBuf, int namePos, int nameLen, FileMode mode) { if (buf == null || buf.Length < ptr + EntrySize(mode, nameLen)) { return false; } mode.CopyTo(buf, ptr); ptr += mode.CopyToLength(); buf[ptr++] = (byte)(' '); System.Array.Copy(nameBuf, namePos, buf, ptr, nameLen); ptr += nameLen; buf[ptr++] = 0; return true; }