Beispiel #1
0
 public void load(string fname)
 {
     using (Stream stm = File.OpenRead(fname))
     {
         data = new byte[stm.Length];
         stm.Read(data, 0, (int)stm.Length);
     }
     using (MemoryStream stream = new MemoryStream(data))
     {
         using (var br = new BinaryReader(stream))
         {
             string pack = new string(br.ReadChars(4));
             if (pack != "PACK")
             {
                 throw new ApplicationException("Invalid pak file: 'PACK' signature not found");
             }
             UInt32 seek = br.ReadUInt32();
             UInt32 size = br.ReadUInt32() / PakItem.HeaderSize;
             br.BaseStream.Seek(seek, SeekOrigin.Begin);
             for (int i = 0; i < size; i++)
             {
                 PakItem item = new PakItem();
                 if (item.Parse(br))
                 {
                     _items.Add(item);
                     br.BaseStream.Seek(PakItem.HeaderSize, SeekOrigin.Current);
                 }
             }
         }
     }
 }
Beispiel #2
0
 public void append(PakItem item)
 {
     _items.Add(item);
 }