コード例 #1
0
        public TES3Record(RecordHeader header, byte[] data) : base(header)
        {
            Subrecords = new List <Subrecord>();

            Version = BitConverter.ToSingle(data, 8).ToString();

            IsMaster = (data[15] == 1);

            // Because C# doesn't like c-strings
            int count = 0;

            while (count <= 32 && data[16 + count] != 0)
            {
                count++;
            }
            Author = Encoding.ASCII.GetString(data, 16, count);

            count = 0;
            while (count <= 265 && data[48 + count] != 0)
            {
                count++;
            }
            Description = Encoding.ASCII.GetString(data, 48, count);

            RecordsNum = BitConverter.ToInt32(data, 304);
        }
コード例 #2
0
        /// <summary>
        /// Attempts to read a record from file,
        /// returns null upon reaching end of file
        /// </summary>
        /// <param name="fs">file stream to read from</param>
        /// <param name="offset">offset to begin from</param>
        /// <returns>A new record or null</returns>
        public Record ReadRecord(FileStream fs)
        {
            byte[] rawHeader = new byte[HEADER_SIZE];
            int    count     = fs.Read(rawHeader, 0, HEADER_SIZE);

            if (count == 0)
            {
                return(null);
            }
            else if (count < 16)
            {
                throw new FormatException("Unexpected file size.");
            }
            bytesRead += count;

            RecordHeader header = new RecordHeader(rawHeader);

            byte[] data = new byte[header.Size];
            count = fs.Read(data, 0, header.Size);
            if (count < header.Size)
            {
                throw new Exception("Unexpected file size.");
            }
            bytesRead += count;

            return(factory.ConstructRecord(header, data));
        }
コード例 #3
0
 public DIALRecord(RecordHeader header, byte[] data) : base(header)
 {
 }
コード例 #4
0
 public Record(RecordHeader header)
 {
     Header = header;
 }