private void FillFolderStartFileIndex()
        {
            FolderStartFileIndex.Clear();
            FileIndexToFolderIndexMap.Clear();

            int folderIndex   = 0;
            int indexInFolder = 0;

            for (int i = 0; i < Files.Count; i++)
            {
                CFileItem file = Files[i];

                bool emptyStream = !file.HasStream;

                if (emptyStream && indexInFolder == 0)
                {
                    FileIndexToFolderIndexMap.Add(-1);
                    continue;
                }

                if (indexInFolder == 0)
                {
                    // v3.13 incorrectly worked with empty folders
                    // v4.07: Loop for skipping empty folders
                    for (;;)
                    {
                        if (folderIndex >= Folders.Count)
                        {
                            throw new InvalidOperationException();
                        }

                        FolderStartFileIndex.Add(i); // check it

                        if (NumUnpackStreamsVector[folderIndex] != 0)
                        {
                            break;
                        }

                        folderIndex++;
                    }
                }

                FileIndexToFolderIndexMap.Add(folderIndex);

                if (emptyStream)
                {
                    continue;
                }

                indexInFolder++;

                if (indexInFolder >= NumUnpackStreamsVector[folderIndex])
                {
                    folderIndex++;
                    indexInFolder = 0;
                }
            }
        }
 internal SevenZipFilePart(Stream stream, ArchiveDatabase database, int index, CFileItem fileEntry)
 {
     this.stream   = stream;
     this.database = database;
     Index         = index;
     Header        = fileEntry;
     if (Header.HasStream)
     {
         Folder = database.Folders[database.FileIndexToFolderIndexMap[index]];
     }
 }