Esempio n. 1
0
        public override ArcFile TryOpen(ArcView file)
        {
            if ('k' != file.View.ReadInt16(4))
            {
                return(null);
            }
            int version = file.View.ReadInt16(6);

            if (1 != version)
            {
                return(null);
            }
            uint data_size = file.View.ReadUInt32(8);
            int  count     = file.View.ReadInt32(0x10);

            if (count <= 0 || count > 0xfffff)
            {
                return(null);
            }
            uint index_size   = (uint)(0x38 * count);
            long base_offset  = 0x18;
            long index_offset = base_offset + data_size;

            if (index_offset >= file.MaxOffset || index_size > file.View.Reserve(index_offset, index_size))
            {
                return(null);
            }
            var dir = new List <Entry> (count);

            for (int i = 0; i < count; ++i)
            {
                var name = file.View.ReadString(index_offset, 0x20);
                index_offset += 0x20;
                var entry = new SPackEntry
                {
                    Name         = name,
                    Offset       = base_offset + file.View.ReadUInt32(index_offset),
                    UnpackedSize = file.View.ReadUInt32(index_offset + 4),
                    Size         = file.View.ReadUInt32(index_offset + 8),
                    Method       = file.View.ReadByte(index_offset + 12),
                    Crc          = file.View.ReadUInt16(index_offset + 14),
                };
                if (!entry.CheckPlacement(file.MaxOffset))
                {
                    return(null);
                }
                if (name.EndsWith(".dat", StringComparison.InvariantCultureIgnoreCase))
                {
                    entry.Type = "audio";
                }
                else
                {
                    entry.Type = FormatCatalog.Instance.GetTypeFromName(name);
                }
                entry.IsPacked = entry.Method != 0;
                dir.Add(entry);
                index_offset += 0x18;
            }
            return(new ArcFile(file, this, dir));
        }
Esempio n. 2
0
 public PackedReader(SPackEntry entry, Stream input)
 {
     m_input = new BinaryReader (input);
     m_packed_size = entry.Size;
     m_output = new byte[entry.UnpackedSize];
 }
Esempio n. 3
0
 public PackedReader(SPackEntry entry, Stream input)
 {
     m_input       = new BinaryReader(input);
     m_packed_size = entry.Size;
     m_output      = new byte[entry.UnpackedSize];
 }
Esempio n. 4
0
 public override ArcFile TryOpen(ArcView file)
 {
     if ('k' != file.View.ReadInt16 (4))
         return null;
     int version = file.View.ReadInt16 (6);
     if (1 != version)
         return null;
     uint data_size = file.View.ReadUInt32 (8);
     int count = file.View.ReadInt32 (0x10);
     if (count <= 0 || count > 0xfffff)
         return null;
     uint index_size = (uint)(0x38 * count);
     long base_offset = 0x18;
     long index_offset = base_offset + data_size;
     if (index_offset >= file.MaxOffset || index_size > file.View.Reserve (index_offset, index_size))
         return null;
     var dir = new List<Entry> (count);
     for (int i = 0; i < count; ++i)
     {
         var name = file.View.ReadString (index_offset, 0x20);
         index_offset += 0x20;
         var entry = new SPackEntry
         {
             Name   = name,
             Offset = base_offset + file.View.ReadUInt32 (index_offset),
             UnpackedSize = file.View.ReadUInt32 (index_offset+4),
             Size   = file.View.ReadUInt32 (index_offset+8),
             Method = file.View.ReadByte (index_offset+12),
             Crc    = file.View.ReadUInt16 (index_offset+14),
         };
         if (!entry.CheckPlacement (file.MaxOffset))
             return null;
         if (name.EndsWith (".dat", StringComparison.InvariantCultureIgnoreCase))
             entry.Type = "audio";
         else
             entry.Type = FormatCatalog.Instance.GetTypeFromName (name);
         entry.IsPacked = entry.Method != 0;
         dir.Add (entry);
         index_offset += 0x18;
     }
     return new ArcFile (file, this, dir);
 }