예제 #1
0
 public PackfileEntry(Packfile packfile, PackfileEntryFileData data, string filename, bool isNew)
 {
     Packfile = packfile;
     Data     = data;
     Filename = filename;
     IsNew    = isNew;
 }
 public PackfileEntry(Packfile packfile, PackfileEntryFileData data, string filename)
 {
     Packfile = packfile;
     Data = data;
     Filename = filename;
 }
예제 #3
0
        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;

            stream.Seek(GetEntryDataOffset(), SeekOrigin.Begin);
            List <PackfileEntryFileData> entryFileData = new List <PackfileEntryFileData>();

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

                if (IsCondensed && IsCompressed)
                {
                    data.Start       = runningPosition;
                    runningPosition += data.Size;
                }
                else if (IsCondensed)
                {
                    data.Start       = runningPosition;
                    runningPosition += data.Size.Align(16);
                }
                else if (IsCompressed)
                {
                    data.Start       = runningPosition;
                    runningPosition += data.CompressedSize.Align(2048);
                }
                entryFileData.Add(data);
            }

            for (int i = 0; i < FileData.NumFiles; i++)
            {
                PackfileEntryFileData data = entryFileData[i];

                stream.Seek(CalculateEntryNamesOffset() + data.FilenameOffset, SeekOrigin.Begin);
                string filename = stream.ReadAsciiNullTerminatedString();
                m_Files.Add(new PackfileEntry(this, data, filename));
            }

            if (IsCondensed && IsCompressed)
            {
                stream.Seek(CalculateDataStartOffset(), SeekOrigin.Begin);

                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 = CalculateDataStartOffset();
            }
        }
예제 #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;
 }