Exemplo n.º 1
0
        internal FPakEntry(BinaryReader reader, EPakVersion Version, int SubVersion, bool caseSensitive, string pakName)
        {
            CompressionBlocks    = null;
            CompressionBlockSize = 0;
            Flags = 0;

            PakFileName = pakName;
            string name = caseSensitive ? reader.ReadFString() : reader.ReadFString().ToLowerInvariant();

            Name = name.StartsWith("/") ? name.Substring(1) : name;

            var StartOffset = reader.BaseStream.Position;

            Offset           = reader.ReadInt64();
            Size             = reader.ReadInt64();
            UncompressedSize = reader.ReadInt64();
            if (Version < EPakVersion.FNAME_BASED_COMPRESSION_METHOD)
            {
                var LegacyCompressionMethod = reader.ReadInt32();
                if (LegacyCompressionMethod == (int)ECompressionFlags.COMPRESS_None)
                {
                    CompressionMethodIndex = 0;
                }
                else if ((LegacyCompressionMethod & (int)ECompressionFlags.COMPRESS_ZLIB) != 0)
                {
                    CompressionMethodIndex = 1;
                }
                else if ((LegacyCompressionMethod & (int)ECompressionFlags.COMPRESS_GZIP) != 0)
                {
                    CompressionMethodIndex = 2;
                }
                else if ((LegacyCompressionMethod & (int)ECompressionFlags.COMPRESS_Custom) != 0)
                {
                    CompressionMethodIndex = 3;
                }
                else
                {
                    // https://github.com/EpicGames/UnrealEngine/blob/8b6414ae4bca5f93b878afadcc41ab518b09984f/Engine/Source/Runtime/PakFile/Public/IPlatformFilePak.h#L441
                    throw new FileLoadException(@"Found an unknown compression type in pak file, will need to be supported for legacy files");
                }
            }
            else
            {
                if (Version == EPakVersion.FNAME_BASED_COMPRESSION_METHOD && SubVersion == 0)
                {
                    CompressionMethodIndex = reader.ReadByte();
                }
                else
                {
                    CompressionMethodIndex = reader.ReadUInt32();
                }
            }
            if (Version < EPakVersion.NO_TIMESTAMPS)
            {
                reader.ReadInt64(); // Timestamp
            }
            reader.ReadBytes(20);   // Hash
            if (Version >= EPakVersion.COMPRESSION_ENCRYPTION)
            {
                if (CompressionMethodIndex != 0)
                {
                    CompressionBlocks = reader.ReadTArray(() => new FPakCompressedBlock(reader));
                }

                Flags = reader.ReadByte();
                CompressionBlockSize = reader.ReadUInt32();
            }

            // Used to seek ahead to the file data instead of parsing the entry again
            StructSize = (int)(reader.BaseStream.Position - StartOffset);
        }
Exemplo n.º 2
0
 public FGame(EGame game, EPakVersion version, int subVersion)
 {
     ActualGame = game;
     Version    = version;
     SubVersion = subVersion;
 }
Exemplo n.º 3
0
 public FGame(EGame game, EPakVersion version)
 {
     ActualGame = game;
     Version    = version;
 }