Ejemplo n.º 1
0
        public Ini1(Stream stream)
        {
            StreamSource = new SharedStreamSource(stream);
            Stream initStream = StreamSource.CreateStream();

            var reader = new BinaryReader(initStream);

            Magic = reader.ReadAscii(4);
            if (Magic != "INI1")
            {
                throw new InvalidDataException("Invalid INI1 file!");
            }

            Size     = reader.ReadInt32();
            KipCount = reader.ReadInt32();

            Kips = new Kip[KipCount];
            int offset = 0x10;

            for (int i = 0; i < KipCount; i++)
            {
                // How to get the KIP's size the lazy way
                var kip = new Kip(StreamSource.CreateStream(offset));

                Kips[i] = new Kip(StreamSource.CreateStream(offset, kip.Size));

                offset += kip.Size;
            }
        }
Ejemplo n.º 2
0
        public Ini1(IStorage storage)
        {
            Storage = storage;

            var reader = new BinaryReader(Storage.AsStream());

            Magic = reader.ReadAscii(4);
            if (Magic != "INI1")
            {
                throw new InvalidDataException("Invalid INI1 file!");
            }

            Size     = reader.ReadInt32();
            KipCount = reader.ReadInt32();

            Kips = new Kip[KipCount];
            int offset = 0x10;

            for (int i = 0; i < KipCount; i++)
            {
                // How to get the KIP's size the lazy way
                var kip = new Kip(Storage.Slice(offset));

                Kips[i] = new Kip(Storage.Slice(offset, kip.Size));

                offset += kip.Size;
            }
        }