public static Bundle Create(Tools.Entry e)
        {
            Bundle res = new Bundle();

            res.chunk = new List <chunktype>();
            foreach (Tools.Field f in e.fields)
            {
                switch (f.fieldname)
                {
                case "path":
                    res.path = (string)f.data;
                    break;

                case "magicSalt":
                    res.salt = BitConverter.ToUInt32((byte[])f.data, 0).ToString("X4");
                    break;

                case "alignMembers":
                    res.align = (bool)f.data;
                    break;

                case "storeCompressedSizes":
                    res.compressed = (bool)f.data;
                    break;

                case "totalSize":
                    res.totalsize = BitConverter.ToUInt64((byte[])f.data, 0);
                    break;

                case "dbxtotalSize":
                    res.dbxtotalsize = BitConverter.ToUInt64((byte[])f.data, 0);
                    break;

                case "ebx":
                    res.ebx = ReadEbx(f);
                    break;

                case "dbx":
                    res.dbx = ReadDbx(f);
                    break;

                case "res":
                    res.res = ReadRes(f);
                    break;

                case "chunks":
                case "chunks0":
                    res.chunk.AddRange(ReadChunks(f));
                    break;
                }
            }
            return(res);
        }
 public static TreeNode MakeEntry(TreeNode t, Tools.Entry e)
 {
     if (e.type == 0x87)
     {
         t.Text = "87 (" + e.type87name + ")";
         return(t);
     }
     if (e.type == 0x82)
     {
         foreach (Tools.Field f in e.fields)
         {
             if (f.type != 0)
             {
                 t.Nodes.Add(MakeField(new TreeNode(f.fieldname), f));
             }
         }
     }
     return(t);
 }
        public static void WriteEntry(Stream s, Tools.Entry e)
        {
            Tools.BinaryWriter7Bit w = new Tools.BinaryWriter7Bit(s);
            switch (e.type)
            {
            case 0x82:
                s.WriteByte(0x82);
                MemoryStream m = new MemoryStream();
                foreach (Tools.Field f in e.fields)
                {
                    WriteField(m, f);
                }
                w.Write7BitEncodedInt((int)m.Length);
                s.Write(m.ToArray(), 0, (int)m.Length);
                break;

            case 0x87:
                w.Write7BitEncodedInt(e.type87name.Length + 1);
                Tools.WriteNullString(s, e.type87name);
                break;
            }
        }