Пример #1
0
        PieceDescriptor[] ReadDescriptors(BinaryReader reader, int count)
        {
            ArrayList result = new ArrayList();

            for (int i = 0; i < count; i++)
            {
                PieceDescriptor descriptor = new PieceDescriptor();
                descriptor.Read(reader);
                result.Add(descriptor);
            }
            return((PieceDescriptor[])result.ToArray(typeof(PieceDescriptor)));
        }
Пример #2
0
        /// <summary>
        /// Gets bounds of the specified piece in the file.
        /// </summary>
        /// <param name="piece">The number od the piece</param>
        /// <param name="start">The start file offset</param>
        /// <param name="end">The end file offset</param>
        public bool GetPieceFileBounds(int piece, out uint start, out uint end)
        {
            start = 0xffffffff;
            end   = 0xffffffff;

            PieceDescriptor pd = _Descriptors[piece];

            uint fc        = pd.Fc;
            bool isUnicode = FileOffset.IsUnicode(fc);

            start = FileOffset.NormalizeFc(fc);

            uint length = _DescriptorOffsets[piece + 1].Value - _DescriptorOffsets[piece].Value;

            end = (uint)(start + length * FileOffset.GetFcDelta(isUnicode));

            return(isUnicode);
        }