Пример #1
0
        CpkEntry GetEntryById(int id)
        {
            Entry entry;

            if (!m_dir.TryGetValue(id, out entry))
            {
                entry = new CpkEntry {
                    Id = id
                };
                m_dir[id] = entry;
            }
            return(entry as CpkEntry);
        }
Пример #2
0
        void ReadToc(long toc_offset)
        {
            var base_offset = Math.Min(m_content_offset, toc_offset);

            if (!m_file.View.AsciiEqual(toc_offset, "TOC "))
            {
                throw new InvalidFormatException();
            }
            var chunk = ReadUTFChunk(toc_offset + 4);
            var table = m_des.DeserializeUTFChunk(chunk);

            foreach (var row in table)
            {
                var entry = new CpkEntry
                {
                    Id     = (int)row["ID"],
                    Offset = (long)row["FileOffset"] + base_offset,
                    Size   = (uint)(int)row["FileSize"],
                };
                if (row.ContainsKey("ExtractSize"))
                {
                    entry.UnpackedSize = (uint)(int)row["ExtractSize"];
                }
                else
                {
                    entry.UnpackedSize = entry.Size;
                }
                entry.IsPacked = entry.Size != entry.UnpackedSize;
                var name = (string)row["FileName"];
                if (row.ContainsKey("DirName"))
                {
                    name = Path.Combine((string)row["DirName"], name);
                }
                entry.Name      = name;
                entry.Type      = FormatCatalog.Instance.GetTypeFromName(name);
                m_dir[entry.Id] = entry;
            }
        }
Пример #3
0
 void ReadToc(long toc_offset)
 {
     var base_offset = Math.Min (m_content_offset, toc_offset);
     if (!m_file.View.AsciiEqual (toc_offset, "TOC "))
         throw new InvalidFormatException();
     var chunk = ReadUTFChunk (toc_offset+4);
     var table = m_des.DeserializeUTFChunk (chunk);
     foreach (var row in table)
     {
         var entry = new CpkEntry
         {
             Id      = (int)row["ID"],
             Offset  = (long)row["FileOffset"] + base_offset,
             Size    = (uint)(int)row["FileSize"],
         };
         if (row.ContainsKey ("ExtractSize"))
             entry.UnpackedSize = (uint)(int)row["ExtractSize"];
         else
             entry.UnpackedSize = entry.Size;
         entry.IsPacked = entry.Size != entry.UnpackedSize;
         var name = (string)row["FileName"];
         if (row.ContainsKey ("DirName"))
             name = Path.Combine ((string)row["DirName"], name);
         entry.Name = name;
         entry.Type = FormatCatalog.Instance.GetTypeFromName (name);
         m_dir[entry.Id] = entry;
     }
 }
Пример #4
0
 CpkEntry GetEntryById(int id)
 {
     Entry entry;
     if (!m_dir.TryGetValue (id, out entry))
     {
         entry = new CpkEntry { Id = id };
         m_dir[id] = entry;
     }
     return entry as CpkEntry;
 }