Beispiel #1
0
            public void Parse(Stream hs)
            {
                ExpectPropertyID(this, hs, PropertyID.kFolder);

                // Folders

                NumFolders = hs.ReadDecodedUInt64();
                External   = hs.ReadByteThrow();
                switch (External)
                {
                case 0:
                    Folders = new Folder[NumFolders];
                    for (ulong i = 0; i < NumFolders; ++i)
                    {
                        Folders[i] = new Folder();
                        Folders[i].Parse(hs);
                    }
                    break;

                case 1:
                    DataStreamsIndex = hs.ReadDecodedUInt64();
                    break;

                default:
                    throw new SevenZipException("External value must be `0` or `1`.");
                }

                ExpectPropertyID(this, hs, PropertyID.kCodersUnPackSize);

                // CodersUnPackSize (data stored in `Folder.UnPackSizes`)

                for (ulong i = 0; i < NumFolders; ++i)
                {
                    Folders[i].UnPackSizes = new UInt64[Folders[i].NumOutStreamsTotal];
                    for (ulong j = 0; j < Folders[i].NumOutStreamsTotal; ++j)
                    {
                        Folders[i].UnPackSizes[j] = hs.ReadDecodedUInt64();
                    }
                }

                // Optional: UnPackDigests (data stored in `Folder.UnPackCRC`)

                PropertyID propertyID = GetPropertyID(this, hs);

                var UnPackDigests = new Digests(NumFolders);

                if (propertyID == PropertyID.kCRC)
                {
                    UnPackDigests.Parse(hs);
                    propertyID = GetPropertyID(this, hs);
                }
                for (ulong i = 0; i < NumFolders; ++i)
                {
                    if (UnPackDigests.Defined(i))
                    {
                        Folders[i].UnPackCRC = UnPackDigests.CRCs[i];
                    }
                }

                // end of UnPackInfo

                if (propertyID != PropertyID.kEnd)
                {
                    throw new SevenZipException("Expected kEnd property.");
                }
            }