Example #1
0
        public static NameRecord Read(BigEndianBinaryReader reader)
        {
            PlatformIDs platform   = reader.ReadUInt16 <PlatformIDs>();
            EncodingIDs encodingId = reader.ReadUInt16 <EncodingIDs>();
            Encoding    encoding   = encodingId.AsEncoding();
            ushort      languageID = reader.ReadUInt16();
            NameIds     nameID     = reader.ReadUInt16 <NameIds>();

            var stringReader = StringLoader.Create(reader, encoding);

            return(new NameRecord(platform, languageID, nameID, string.Empty)
            {
                StringReader = stringReader
            });
        }
Example #2
0
        public static NameRecord Read(BinaryReader reader)
        {
            var         platform   = reader.ReadUInt16 <PlatformIDs>();
            EncodingIDs encodingId = reader.ReadUInt16 <EncodingIDs>();
            Encoding    encoding   = encodingId.AsEncoding();
            var         languageID = reader.ReadUInt16();
            var         nameID     = reader.ReadUInt16 <NameIds>();

            var stringReader = StringLoader.Create(reader, encoding);

            return(new NameRecord(platform, languageID, nameID, null)
            {
                StringReader = stringReader
            });
        }
Example #3
0
        public static NameTable Load(BinaryReader reader)
        {
            var    strings      = new List <StringLoader>();
            ushort format       = reader.ReadUInt16();
            ushort nameCount    = reader.ReadUInt16();
            ushort stringOffset = reader.ReadUInt16();

            var names = new NameRecord[nameCount];

            for (int i = 0; i < nameCount; i++)
            {
                names[i] = NameRecord.Read(reader);
                StringLoader?sr = names[i].StringReader;
                if (sr is object)
                {
                    strings.Add(sr);
                }
            }

            var langs = new StringLoader[0];

            if (format == 1)
            {
                // format 1 adds language data
                ushort langCount = reader.ReadUInt16();
                langs = new StringLoader[langCount];

                for (int i = 0; i < langCount; i++)
                {
                    langs[i] = StringLoader.Create(reader);
                    strings.Add(langs[i]);
                }
            }

            foreach (StringLoader readable in strings.OrderBy(x => x.Offset))
            {
                int diff = stringOffset + readable.Offset;

                // only seek forward, if we find issues with this we will consume forwards as the idea is we will never need to backtrack
                reader.Seek(diff, SeekOrigin.Begin);

                readable.LoadValue(reader);
            }

            string[] langNames = langs?.Select(x => x.Value).ToArray() ?? new string[0];

            return(new NameTable(names, langNames));
        }