Example #1
0
        public byte[] GetFileInner(int index)
        {
            if (NumFiles <= index)
            {
                return(null);
            }

            BinaryReader DataReader = managedFile.GetReader();

            pakExtractedBuffer = null;
            if (SkipFlags[index] != 1)
            {
                DataReader.BaseStream.Position = (long)DataOffsets[index];
                if (CompressedFlags[index] == 1)
                {
                    long   length3          = (long)DataReader.ReadInt32();
                    byte[] compressedBuffer = DataReader.ReadBytes(DataSizes[index] - 4);

                    pakExtractedBuffer = new byte[length3];
                    LZFuncs.LZDecomp(out pakExtractedBuffer, compressedBuffer, (uint)length3, (uint)compressedBuffer.Length);
                }
                else
                {
                    pakExtractedBuffer = DataReader.ReadBytes(DataSizes[index]);
                }
            }


            return(pakExtractedBuffer);
        }
Example #2
0
        private bool Initialize()
        {
            BinaryReader binaryReader = managedFile.GetReader(0);
            int          length       = binaryReader.ReadInt32();

            FSTFile.TOCEntry[] tocEntryArray = new FSTFile.TOCEntry[length];
            List <byte[]>      list          = new List <byte[]>();

            for (int index = 0; index < length; ++index)
            {
                tocEntryArray[index].Offset           = binaryReader.ReadUInt32();
                tocEntryArray[index].CompressedSize   = binaryReader.ReadUInt32();
                tocEntryArray[index].UncompressedSize = binaryReader.ReadUInt32();
                tocEntryArray[index].Filename         = new string(binaryReader.ReadChars(250)).TrimEnd(new char[1]).Replace(@"data\", "").ToUpper();
            }
            for (int index = 0; index < length; ++index)
            {
                byte[] outputBuffer = new byte[tocEntryArray[index].UncompressedSize];
                if ((int)tocEntryArray[index].CompressedSize == (int)tocEntryArray[index].UncompressedSize)
                {
                    outputBuffer = binaryReader.ReadBytes((int)tocEntryArray[index].CompressedSize);
                }
                else
                {
                    LZFuncs.LZDecomp(out outputBuffer, binaryReader.ReadBytes((int)tocEntryArray[index].CompressedSize)
                                     , tocEntryArray[index].UncompressedSize,
                                     tocEntryArray[index].CompressedSize);
                }
                list.Add(outputBuffer);
            }
            for (int index = 0; index < length; ++index)
            {
                //Debug.Log("Added "+tocEntryArray[index].Filename);
                filesOnFst.Add(tocEntryArray[index].Filename, list[index]);
            }

            return(true);
        }