Beispiel #1
0
        public byte[] ReadFile(string path)
        {
            var          file = files.Where(x => x.filePath.ToLower().Contains(path.ToLower())).ToList();
            MemoryStream ms   = new MemoryStream();

            if (file.Count > 0)
            {
                fileTableEntry f  = file.First();
                PckReader      br = new PckReader(pck_path);
                br.Seek(f.fileDataOffset, SeekOrigin.Begin);
                byte[] buffer = br.ReadBytes(f.fileDataCompressedSize);
                if (f.fileDataCompressedSize < f.fileDataDecompressedSize)
                {
                    ZOutputStream zos = new ZOutputStream(ms);
                    CopyStream(new MemoryStream(buffer), zos, f.fileDataCompressedSize);
                }
                else
                {
                    return(buffer);
                }
            }
            return(ms.ToArray());
        }
Beispiel #2
0
 public void Load(string path)
 {
     new Thread(delegate()
     {
         pck_path     = path;
         PckReader br = new PckReader(path);
         br.Seek(-8, SeekOrigin.End);
         int entryCount = br.ReadInt32();
         br.Seek(-272, SeekOrigin.End);
         long fileTableOffset = (long)((ulong)((uint)(br.ReadUInt32() ^ (ulong)KEY_1)));
         br.Seek(fileTableOffset, SeekOrigin.Begin);
         SetProgressMaximum(entryCount);
         for (int a = 0; a < entryCount; ++a)
         {
             SetProgressValue(a);
             int entrySize = br.ReadInt32() ^ KEY_1;
             br.ReadInt32();
             byte[] buffer = br.ReadBytes(entrySize);
             files.Add(entrySize < 276 ? readTableEntry(buffer, true) : readTableEntry(buffer, false));
         }
         SetProgressValue(0);
         br.Close();
     }).Start();
 }