protected void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_dataReader != null)
                {
                    _dataReader.Close();
                }
            }

            _conditionals = null;
        }
        public static ConditionalsFile Load(string path)
        {
            var conditionalsFile = new ConditionalsFile();

            using (var reader = new DataReader(new FileStream(path, FileMode.Open)))
            {
                var _buffer = reader.ReadBytes((int)reader.Length);

                reader.Seek(0);

                var headerId = reader.ReadInt32();

                if (headerId != ConditionalsFile.ValidHeaderId)
                {
                    reader.Close();

                    return(null);
                }

                var version = reader.ReadInt32();

                if (version != 1)
                {
                    reader.Close();

                    return(null);
                }

                var unknownInt16 = reader.ReadInt16();
                var count        = reader.ReadInt16();
                var entries      = new ConditionalEntries();

                for (var i = 0; i < count; i++)
                {
                    var temp = new ConditionalEntry
                    {
                        Id         = reader.ReadInt32(),
                        Offset     = reader.ReadInt32(),
                        ListOffset = i * 8 + 12,
                        Size       = -1
                    };

                    entries.Add(temp);
                }

                // Sort by Offset
                entries = new ConditionalEntries(entries.OrderBy(entry => entry.Offset));

                CalculateEntriesSize(entries, reader.Length);

                foreach (var entry in entries)
                {
                    entry.Data = new byte[entry.Size];

                    reader.Seek(entry.Offset);
                    reader.Read(entry.Data, 0, entry.Size);
                }

                // Sort by Id
                conditionalsFile.Entries = new ConditionalEntries(entries.OrderBy(entry => entry.Id));
            }

            return(conditionalsFile);
        }
 protected ConditionalsReader(bool leaveOpen = false)
 {
     _conditionals = new ConditionalsFile();
     _rawBytes     = new byte[] {};
     _leaveOpen    = leaveOpen;
 }
Esempio n. 4
0
        public static ConditionalsFile Load(string path)
        {
            var result = new ConditionalsFile();

            return(result);
        }