コード例 #1
0
        public byte[] ItemData(string name)
        {
            HogItem item = index[name];
            var     ret  = new byte[item.dataSize];

            Array.Copy(data, item.dataOfs, ret, 0, item.dataSize);
            return(ret);
        }
コード例 #2
0
        private void load(string filename)
        {
            data = File.ReadAllBytes(filename);
            size = data.Length;
            if (!data.Take(3).SequenceEqual(new byte[] { (byte)'D', (byte)'H', (byte)'F' }))
            {
                throw new Exception("invalid header");
            }
            items = new List <HogItem>();
            index = new Dictionary <string, HogItem>();
            int ofs = 3;

            while (ofs < size)
            {
                HogItem item = new HogItem(data, ofs);
                Debug.WriteLine(item.name);
                //Debug.WriteLine(item.dataSize);
                ofs = item.dataOfs + item.dataSize;
                items.Add(item);
                index.Add(item.name, item);
            }
        }