コード例 #1
0
 public DataSection(GeneralSection section, DidxItem[] items)
 {
     _items              = items;
     Section             = section.Section;
     Data                = section.Data;
     LengthOfSectionData = section.LengthOfSectionData;
 }
コード例 #2
0
ファイル: DidxSection.cs プロジェクト: Mattish/BoteTools
 public DidxSection(GeneralSection section)
 {
     _amount             = section.Data.Length / 12;
     Section             = section.Section;
     Data                = section.Data;
     LengthOfSectionData = section.LengthOfSectionData;
 }
コード例 #3
0
ファイル: GeneralSection.cs プロジェクト: Mattish/BoteTools
 public static long Create(byte[] file, long index, out GeneralSection section)
 {
     section         = new GeneralSection();
     section.Section = new byte[4];
     Array.Copy(file, index, section.Section, 0, 4);
     section.LengthOfSectionData = BitConverter.ToUInt32(file, (int)(index + 4));
     section.Data = new byte[section.LengthOfSectionData];
     Array.Copy(file, index + 8, section.Data, 0, section.LengthOfSectionData);
     return(index + 8 + section.LengthOfSectionData);
 }
コード例 #4
0
        private void Load()
        {
            if (_hasLoadedBefore)
            {
                throw new FileLoadException("Already loaded this file.");
            }
            _hasLoadedBefore = true;

            _generalSections = new List <GeneralSection>();

            var bytes     = File.ReadAllBytes(_filePath);
            var nextIndex = 0L;

            while (nextIndex < bytes.Length)
            {
                GeneralSection section;
                nextIndex = GeneralSection.Create(bytes, nextIndex, out section);
                switch (section.SectionAsString)
                {
                case "DIDX":
                    _didx   = new DidxSection(section);
                    section = _didx;
                    break;

                case "DATA":
                    _data   = new DataSection(section, _didx.Items);
                    section = _data;
                    break;

                case "HIRC":
                    _hirc   = new HircSection(section);
                    section = _hirc;
                    break;
                }
                section.Process();
                _generalSections.Add(section);
            }
            var memoryStream = new MemoryStream();

            foreach (var generalSection in _generalSections)
            {
                var bytesToWrite = generalSection.ToBytes();
                memoryStream.Write(bytesToWrite, 0, bytesToWrite.Length);
            }
            var memoryStreamBuffer = memoryStream.ToArray();

            for (int i = 0; i < memoryStream.Length; i++)
            {
                if (memoryStreamBuffer[i] != bytes[i])
                {
                    throw new Exception("Weeeep!");
                }
            }
        }
コード例 #5
0
 public HircSection(GeneralSection section)
 {
     Section             = section.Section;
     Data                = section.Data;
     LengthOfSectionData = section.LengthOfSectionData;
 }