Exemplo n.º 1
0
 private void AddOrganizedFile(FileLUT.IncludedFile in_file, ref ulong io_uDataOffset)
 {
     System.Diagnostics.Debug.Assert(!in_file.Included);
     io_uDataOffset += ComputePaddingSize(in_file.uBlockSize, io_uDataOffset);
     // Starting block is expressed in terms of this file's own block size.
     System.Diagnostics.Debug.Assert(io_uDataOffset % in_file.uBlockSize == 0);
     in_file.uStartingBlock = (uint)(io_uDataOffset / in_file.uBlockSize);
     m_arOrganizedFileEntries.Add(in_file);
     in_file.Included = true;
     io_uDataOffset  += in_file.uFileSize;
 }
Exemplo n.º 2
0
        public void OrganizeFiles(ulong in_uDataOffset, List <OrderedFile> in_listOrderedFiles, Dictionary <string, uint> in_mapLanguages, IProgressNotificationsDispatcher in_notifDispatcher)
        {
            // Build list of files based on specified file order.
            if (in_listOrderedFiles != null)
            {
                foreach (OrderedFile orderedFile in in_listOrderedFiles)
                {
                    // Select proper LUT.
                    FileLUT lut = m_arFileLUTs[orderedFile.Type];

                    // Find file (binary search: files in LUTs are sorted in ID/LanguageID.
                    uint uLanguageID;
                    if (in_mapLanguages.TryGetValue(orderedFile.Language, out uLanguageID))
                    {
                        int iFileIndex = lut.FindEntry(orderedFile.Id, uLanguageID);
                        if (iFileIndex >= 0)
                        {
                            FileLUT.IncludedFile file = lut.GetAt(iFileIndex);

                            // File was laid out.
                            // Set starting block, mark as ready.
                            AddOrganizedFile(file, ref in_uDataOffset);
                        }
                        else
                        {
                            // File specified in layout is not in the LUT.
                            in_notifDispatcher.NotifyLogMsg("WARNING: File " + orderedFile.ShortName + " specified in the layout is missing.");
                        }
                    }
                    else
                    {
                        // Invalid language.
                        in_notifDispatcher.NotifyLogMsg("WARNING: File " + orderedFile.ShortName + " specified in the layout has invalid language + " + orderedFile.Language + ".");
                    }
                }
            }

            // Default logic: add files of all LUTs in order.

            // Set each file's starting block.
            foreach (FileLUT lut in m_arFileLUTs.Values)
            {
                foreach (FileLUT.IncludedFile file in lut)
                {
                    if (!file.Included)
                    {
                        AddOrganizedFile(file, ref in_uDataOffset);
                    }
                }
            }
        }