CSPspEmu.Hle.Formats.Dax.SetStream C# (CSharp) Method

SetStream() public method

public SetStream ( Stream Stream ) : void
Stream Stream
return void
        public void SetStream(Stream Stream)
        {
            this.Stream = Stream;

            // Read the header.
            this.Header = this.Stream.ReadStruct<HeaderStruct>();
            if (this.Header.Magic != DAXFILE_SIGNATURE)
            {
                throw (new InvalidDataException("Not a DAX File"));
            }

            var TotalBlocks = Header.TotalBlocks;

            //Header.TotalBlocks
            var Offsets = this.Stream.ReadStructVector<uint>(TotalBlocks);
            var Sizes = this.Stream.ReadStructVector<ushort>(TotalBlocks);
            NCArea[] NCAreas = null;

            if (Header.Version >= Version.DAXFORMAT_VERSION_1)
            {
                NCAreas = this.Stream.ReadStructVector<NCArea>(Header.NCAreas);
            }

            Blocks = new BlockInfo[TotalBlocks];
            for (int n = 0; n < TotalBlocks; n++)
            {
                Blocks[n].Position = Offsets[n];
                Blocks[n].Length = Sizes[n];
                Blocks[n].IsCompressed = true;
            }
            if (Header.Version >= Version.DAXFORMAT_VERSION_1)
            {
                foreach (var NCArea in NCAreas)
                {
                    //Console.WriteLine("{0}-{1}", NCArea.frame, NCArea.size);
                    for (int n = 0; n < NCArea.Size; n++)
                    {
                        Blocks[NCArea.Frame + n].IsCompressed = false;
                    }
                }
            }
        }