Exemple #1
0
        public void Read(Stream stream)
        {
            using var reader = new ErpBinaryReader(EndianBitConverter.Little, stream);
            var magic = reader.ReadUInt32();

            if (magic != 1263555141)
            {
                throw new Exception("This is not an ERP file!");
            }

            Version = reader.ReadInt32();
            reader.ReadBytes(8); // padding
            reader.ReadBytes(8); // info offset
            reader.ReadBytes(8); // info size

            ResourceOffset = reader.ReadUInt64();
            reader.ReadBytes(8); // padding

            var numFiles    = reader.ReadInt32();
            var numTempFile = reader.ReadInt32();

            for (var i = 0; i < numFiles; ++i)
            {
                var entry = new ErpResource(this);
                entry.Read(reader);
                Resources.Add(entry);
            }
        }
Exemple #2
0
 public void Import(Stream stream)
 {
     using (ErpBinaryReader reader = new ErpBinaryReader(EndianBitConverter.Little, stream))
     {
         this.SetData(reader.ReadBytes((int)reader.BaseStream.Length));
     }
 }
        public void Read(ErpBinaryReader reader)
        {
            reader.ReadBytes(4); // entry info length
            this.Identifier   = reader.ReadString(reader.ReadInt16());
            this.ResourceType = reader.ReadString(16);

            this.Unknown = reader.ReadInt32();

            byte numResources = reader.ReadByte();

            while (numResources-- > 0)
            {
                ErpFragment res = new ErpFragment(this.ParentFile);
                res.Read(reader);
                this.Fragments.Add(res);
            }

            if (this.ParentFile.Version > 2)
            {
                this.Hash = reader.ReadBytes(16);
            }
        }
Exemple #4
0
        public void Read(ErpBinaryReader reader)
        {
            this.Name = reader.ReadString(4);

            this.Offset = reader.ReadUInt64();
            this.Size   = reader.ReadUInt64();
            this.Flags  = reader.ReadInt32();

            if (this.ParentFile.Version > 2)
            {
                this.Compression = (ErpCompressionAlgorithm)reader.ReadByte();
                this.PackedSize  = reader.ReadUInt64();
            }
            else
            {
                this.PackedSize = this.Size;
            }

            int pos = (int)reader.BaseStream.Position;

            reader.Seek((int)(this.ParentFile.ResourceOffset + this.Offset), SeekOrigin.Begin);
            this._data = reader.ReadBytes((int)this.PackedSize);
            reader.Seek(pos, SeekOrigin.Begin);
        }
Exemple #5
0
        public void Read(ErpBinaryReader reader)
        {
            Name = reader.ReadString(4);

            Offset = reader.ReadUInt64();
            Size   = reader.ReadUInt64();
            Flags  = reader.ReadInt32();

            if (ParentFile.Version > 2)
            {
                Compression = (ErpCompressionAlgorithm)reader.ReadByte();
                PackedSize  = reader.ReadUInt64();
            }
            else
            {
                PackedSize = Size;
            }

            var pos = Convert.ToInt32(reader.BaseStream.Position);

            reader.Seek(Convert.ToInt32(ParentFile.ResourceOffset + Offset), SeekOrigin.Begin);
            _data = reader.ReadBytes(Convert.ToInt32(PackedSize));
            reader.Seek(pos, SeekOrigin.Begin);
        }