예제 #1
0
        private static List <MimeAppleTranscoder.EntryDescriptor> ReadAppleFileHeaderEntries(Stream applefileStream)
        {
            int num = MimeAppleTranscoder.ReadUIntFromStream(applefileStream);

            if (num != 131072)
            {
                throw new MimeException(EmailMessageStrings.WrongAppleVersionNumber);
            }
            applefileStream.Position += 16L;
            int num2 = MimeAppleTranscoder.ReadUShortFromStream(applefileStream);

            if (num2 > 100)
            {
                throw new MimeException(EmailMessageStrings.TooManyEntriesInApplefile);
            }
            List <MimeAppleTranscoder.EntryDescriptor> list = new List <MimeAppleTranscoder.EntryDescriptor>(num2);

            for (int i = 0; i < num2; i++)
            {
                int entryId = MimeAppleTranscoder.ReadUIntFromStream(applefileStream);
                int num3    = MimeAppleTranscoder.ReadUIntFromStream(applefileStream);
                int num4    = MimeAppleTranscoder.ReadUIntFromStream(applefileStream);
                if ((long)num3 < applefileStream.Position || (long)num3 > applefileStream.Length || num4 < 0 || (long)(num4 + num3) > applefileStream.Length)
                {
                    throw new MimeException(EmailMessageStrings.WrongOffsetsInApplefile);
                }
                MimeAppleTranscoder.EntryDescriptor item = new MimeAppleTranscoder.EntryDescriptor(entryId, num3, num4);
                list.Add(item);
            }
            list.Sort(new Comparison <MimeAppleTranscoder.EntryDescriptor>(MimeAppleTranscoder.EntryDescriptor.CompareByOffset));
            return(list);
        }