Exemplo n.º 1
0
        /// <summary>
        /// Reads the Central Directory to populate the list of files
        /// </summary>
        /// <param name="buffstream">The Stream to read from</param>
        private void PopulateEntries(Stream buffstream)
        {
            buffstream.Seek(EOFStrct.CDOffset, SeekOrigin.Begin);
            Entries = new List <ZipEntryFull>();
            int count = 0;

            while (count < EOFStrct.CDSize)
            {
                byte[] buff    = BuffXOR(buffstream, 34);                                                                                  // Read up until all the variable field lengths have been read
                int    bufsize = BitConverter.ToUInt16(buff, 28) + BitConverter.ToUInt16(buff, 30) + BitConverter.ToUInt16(buff, 32) + 46; // Add them onto the total block size
                buffstream.Seek(-34, SeekOrigin.Current);                                                                                  // Rewind back to the start of the entry
                buff = BuffXOR(buffstream, bufsize);                                                                                       // Re-read the XOR
                ZipEntryFull entry = new ZipEntryFull(buff, this);
                Entries.Add(entry);
                count += bufsize;
            }
            if (buffstream.Position != EOFRecordOff)
            {
                throw new FormatException("End of CD doesn't match position of EOFRecord");
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Reads the Central Directory to populate the list of files
 /// </summary>
 /// <param name="buffstream">The Stream to read from</param>
 private void PopulateEntries(Stream buffstream)
 {
     buffstream.Seek(EOFStrct.CDOffset, SeekOrigin.Begin);
     Entries = new List<ZipEntryFull>();
     int count = 0;
     while (count < EOFStrct.CDSize)
     {
         byte[] buff = BuffXOR(buffstream, 34); // Read up until all the variable field lengths have been read
         int bufsize = BitConverter.ToUInt16(buff, 28) + BitConverter.ToUInt16(buff, 30) + BitConverter.ToUInt16(buff, 32) + 46; // Add them onto the total block size
         buffstream.Seek(-34, SeekOrigin.Current); // Rewind back to the start of the entry
         buff = BuffXOR(buffstream, bufsize); // Re-read the XOR
         ZipEntryFull entry = new ZipEntryFull(buff, this);
         Entries.Add(entry);
         count += bufsize;
     }
     if (buffstream.Position != EOFRecordOff)
         throw new FormatException("End of CD doesn't match position of EOFRecord");
 }