示例#1
0
 public PackfileEntry(Packfile packfile, PackfileEntryFileData data, string filename, bool isNew)
 {
     Packfile = packfile;
     Data     = data;
     Filename = filename;
     IsNew    = isNew;
 }
        public Packfile(Stream stream, bool isStr2)
        {
            IsStr2 = isStr2;
            stream.Seek(0, SeekOrigin.Begin);
            FileData = stream.ReadStruct <PackfileFileData>();

            m_Files = new List <IPackfileEntry>();

            uint runningPosition = 0;
            List <PackfileEntryFileData> entryFileData = new List <PackfileEntryFileData>();

            for (int i = 0; i < FileData.NumFiles; i++)
            {
                PackfileEntryFileData data = stream.ReadStruct <PackfileEntryFileData>();

                if (IsCondensed && IsCompressed)
                {
                    data.Flags       = 0;
                    data.Start       = runningPosition;
                    runningPosition += data.Size;
                }
                else if (IsCondensed)
                {
                    data.Start       = runningPosition;
                    runningPosition += data.Size.Align(16);
                }

                entryFileData.Add(data);
            }

            for (int i = 0; i < FileData.NumFiles; i++)
            {
                stream.Align(2);
                string filename = stream.ReadAsciiNullTerminatedString();
                stream.Seek(1, SeekOrigin.Current);
                m_Files.Add(new PackfileEntry(this, entryFileData[i], filename));
                stream.Align(2);
            }

            if (IsCondensed && IsCompressed)
            {
                DataOffset = 0;
                byte[] compressedData = new byte[FileData.CompressedDataSize];
                stream.Read(compressedData, 0, (int)FileData.CompressedDataSize);
                using (MemoryStream tempStream = new MemoryStream(compressedData))
                {
                    using (Stream s = new ZlibStream(tempStream, CompressionMode.Decompress, true))
                    {
                        byte[] uncompressedData = new byte[FileData.DataSize];
                        s.Read(uncompressedData, 0, (int)FileData.DataSize);
                        DataStream = new MemoryStream(uncompressedData);
                    }
                }
            }
            else
            {
                DataStream = stream;
                DataOffset = stream.Position;
            }
        }
示例#3
0
 public PackfileEntry(Packfile packfile, PackfileEntryFileData data, string filename)
 {
     Packfile = packfile;
     Data     = data;
     Filename = filename;
 }
示例#4
0
 public PackfileEntry(Packfile packfile, PackfileEntryFileData data, string filename) : this(packfile, data, filename, false)
 {
 }
 public PackfileEntry(Packfile packfile, PackfileEntryFileData data, string filename)
 {
     Packfile = packfile;
     Data = data;
     Filename = filename;
 }