Esempio n. 1
0
        public List <Entry> ReadIndex()
        {
            if (m_data_offset > m_file.View.Reserve(0, m_data_offset))
            {
                return(null);
            }
            uint index_offset = 0x10;

            m_name_pos = index_offset + (uint)m_dir_count * 8u + (uint)m_count * 0x10u;
            var dirs = new DirEntry[m_dir_count];

            for (int i = 0; i < m_dir_count; ++i)
            {
                dirs[i].Parent    = m_file.View.ReadInt32(index_offset);
                dirs[i].LastIndex = m_file.View.ReadInt32(index_offset + 4);
                if (dirs[i].Parent >= m_dir_count || dirs[i].Parent == i)
                {
                    return(null);
                }
                if (-1 != dirs[i].Parent)
                {
                    dirs[i].Name = ReadNextName();
                }
                index_offset += 8;
            }
            var files   = new List <Entry> (m_count);
            int current = 0;

            for (int i = 0; i < m_dir_count; ++i)
            {
                string parent_dir = GetPath(dirs, i);
                while (current < dirs[i].LastIndex)
                {
                    string name  = Path.Combine(parent_dir, ReadNextName());
                    var    entry = FormatCatalog.Instance.Create <Entry> (name);
                    entry.Offset = m_file.View.ReadUInt32(index_offset);
                    entry.Size   = m_file.View.ReadUInt32(index_offset + 4);
                    files.Add(entry);
                    index_offset += 0x10;
                    ++current;
                }
            }
            return(files);
        }
Esempio n. 2
0
 public List<Entry> ReadIndex()
 {
     if (m_data_offset > m_file.View.Reserve (0, m_data_offset))
         return null;
     uint index_offset = 0x10;
     m_name_pos = index_offset + (uint)m_dir_count * 8u + (uint)m_count * 0x10u;
     var dirs = new DirEntry[m_dir_count];
     for (int i = 0; i < m_dir_count; ++i)
     {
         dirs[i].Parent    = m_file.View.ReadInt32 (index_offset);
         dirs[i].LastIndex = m_file.View.ReadInt32 (index_offset+4);
         if (dirs[i].Parent >= m_dir_count || dirs[i].Parent == i)
             return null;
         if (-1 != dirs[i].Parent)
             dirs[i].Name = ReadNextName();
         index_offset += 8;
     }
     var files = new List<Entry> (m_count);
     int current = 0;
     for (int i = 0; i < m_dir_count; ++i)
     {
         string parent_dir = GetPath (dirs, i);
         while (current < dirs[i].LastIndex)
         {
             string name = Path.Combine (parent_dir, ReadNextName());
             var entry = FormatCatalog.Instance.Create<Entry> (name);
             entry.Offset = m_file.View.ReadUInt32 (index_offset);
             entry.Size   = m_file.View.ReadUInt32 (index_offset+4);
             files.Add (entry);
             index_offset += 0x10;
             ++current;
         }
     }
     return files;
 }