LSLib.Granny.GR2.GR2Reader.Read C# (CSharp) Method

Read() public method

public Read ( object root ) : void
root object
return void
        public void Read(object root)
        {
            using (this.InputReader = new BinaryReader(InputStream))
            {
                Magic = ReadMagic();

                if (Magic.format != Magic.Format.LittleEndian32 && Magic.format != Magic.Format.LittleEndian64)
                    throw new ParsingException("Only little-endian GR2 files are supported");

                Header = ReadHeader();
                for (int i = 0; i < Header.numSections; i++)
                {
                    var section = new Section();
                    section.Header = ReadSectionHeader();
                    Sections.Add(section);
                }

                Debug.Assert(InputStream.Position == Magic.headersSize);

                UncompressStream();

                foreach (var section in Sections)
                {
                    ReadSectionRelocations(section);
                }

                if (Magic.IsLittleEndian != BitConverter.IsLittleEndian)
                {
                    // TODO: This should be done before applying relocations?
                    foreach (var section in Sections)
                    {
                        ReadSectionMixedMarshallingRelocations(section);
                    }
                }

                var rootStruct = new StructReference();
                rootStruct.Offset = Sections[(int)Header.rootType.Section].Header.offsetInFile + Header.rootType.Offset;

                Seek(Header.rootNode);
                ReadStruct(rootStruct.Resolve(this), MemberType.Inline, root, null);
            }
        }

Usage Example

コード例 #1
0
ファイル: Exporter.cs プロジェクト: Norbyte/lslib
 private Root LoadGR2(string inPath)
 {
     var root = new LSLib.Granny.Model.Root();
     FileStream fs = new FileStream(inPath, FileMode.Open, System.IO.FileAccess.Read, FileShare.ReadWrite);
     var gr2 = new LSLib.Granny.GR2.GR2Reader(fs);
     gr2.Read(root);
     root.PostLoad();
     fs.Close();
     fs.Dispose();
     return root;
 }
All Usage Examples Of LSLib.Granny.GR2.GR2Reader::Read