CSPspEmu.Hle.Formats.Pbp.Load C# (CSharp) Method

Load() public method

public Load ( Stream Stream ) : Pbp
Stream Stream
return Pbp
        public Pbp Load(Stream Stream)
        {
            this.Stream = Stream;
            this.Header = Stream.ReadStruct<HeaderStruct>();
            this.Files = new Dictionary<string, Stream>();

            if (Header.Magic != HeaderStruct.MagicEnum.ExpectedValue)
            {
                throw(new Exception("Not a PBP file"));
            }

            var Offsets = Header.Offsets.Concat(new[] { (uint)Stream.Length }).ToArray();

            for (int n = 0; n < 8; n++)
            {
                Files[Names[n]] = Stream.SliceWithBounds(Offsets[n + 0], Offsets[n + 1]);
            }

            return this;
        }

Usage Example

Example #1
0
 public void LoadTest()
 {
     var Pbp = new Pbp();
     Pbp.Load(File.OpenRead("../../../TestInput/HelloJpcsp.pbp"));
 }