Exemple #1
0
        private void LoadFile(string filename)
        {
            int dataOffset = 0;

            if (System.IO.File.Exists(filename) == false)
            {
                return;
            }

            System.IO.BinaryReader fileA;

            try
            {
                System.IO.FileStream fsA = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);

                fileA = new System.IO.BinaryReader(fsA);
            }
            catch (System.ApplicationException)
            {
                return;
            }

            dataOffset = fileA.ReadInt16() + 2;

            List <DaxHeaderEntry> headers = new List <DaxHeaderEntry>();

            const int headerEntrySize = 9;

            for (int i = 0; i < ((dataOffset - 2) / headerEntrySize); i++)
            {
                DaxHeaderEntry dhe = new DaxHeaderEntry();
                dhe.id       = fileA.ReadByte();
                dhe.offset   = fileA.ReadInt32();
                dhe.rawSize  = fileA.ReadInt16();
                dhe.compSize = fileA.ReadUInt16();

                headers.Add(dhe);
            }

            foreach (DaxHeaderEntry dhe in headers)
            {
                byte[] comp = new byte[dhe.compSize];
                byte[] raw  = new byte[dhe.rawSize];

                fileA.BaseStream.Seek(dataOffset + dhe.offset, System.IO.SeekOrigin.Begin);

                comp = fileA.ReadBytes(dhe.compSize);

                Decode(dhe.rawSize, dhe.compSize, raw, comp);

                entries.Add(dhe.id, raw);
            }

            fileA.Close();
        }
Exemple #2
0
        private void LoadFile(string filename)
        {
            System.IO.BinaryReader fileReader;

            System.IO.FileStream fileStream = new System.IO.FileStream(filename, System.IO.FileMode.Open,
                                                                       System.IO.FileAccess.Read, System.IO.FileShare.Read);

            fileReader = new System.IO.BinaryReader(fileStream);

            int dataOffset = fileReader.ReadInt16();

            List <DaxHeaderEntry> headers = new List <DaxHeaderEntry>();

            const int headerEntrySize = 9;

            for (int i = 0; i < (dataOffset / headerEntrySize); i++)
            {
                DaxHeaderEntry header = new DaxHeaderEntry();
                header.Id             = fileReader.ReadByte();
                header.Offset         = fileReader.ReadInt32();
                header.DataSize       = fileReader.ReadInt16();
                header.CompressedSize = fileReader.ReadUInt16();

                headers.Add(header);
            }

            foreach (DaxHeaderEntry header in headers)
            {
                byte[] compressed = fileReader.ReadBytes(header.CompressedSize);

                byte[] data = Extract(header.DataSize, compressed);

                _entries.Add(header.Id, data);
                // next entry should start with header.Offset but it also starts with cursor position
                // check would be nice but isn't necessary
            }

            fileReader.Close();
        }
Exemple #3
0
        private void LoadFile(string filename)
        {
            int dataOffset = 0;

            if (System.IO.File.Exists(filename) == false)
            {
                return;
            }

            System.IO.BinaryReader fileA;

            try
            {
                System.IO.FileStream fsA = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);

                fileA = new System.IO.BinaryReader(fsA);
            }
            catch (System.ApplicationException)
            {
                return;
            }

            dataOffset = fileA.ReadInt16() + 2;

            List<DaxHeaderEntry> headers = new List<DaxHeaderEntry>();

            const int headerEntrySize = 9;

            for (int i = 0; i < ((dataOffset - 2) / headerEntrySize); i++)
            {
                DaxHeaderEntry dhe = new DaxHeaderEntry();
                dhe.id = fileA.ReadByte();
                dhe.offset = fileA.ReadInt32();
                dhe.rawSize = fileA.ReadInt16();
                dhe.compSize = fileA.ReadUInt16();

                headers.Add(dhe);
            }

            foreach (DaxHeaderEntry dhe in headers)
            {
                byte[] comp = new byte[dhe.compSize];
                byte[] raw = new byte[dhe.rawSize];

                fileA.BaseStream.Seek(dataOffset + dhe.offset, System.IO.SeekOrigin.Begin);

                comp = fileA.ReadBytes(dhe.compSize);

                Decode(dhe.rawSize, dhe.compSize, raw, comp);

                entries.Add(dhe.id, raw);
            }

            fileA.Close();
        }