Exemplo n.º 1
0
 /// <summary>
 /// Adds a WzDirectory to the list of sub directories
 /// </summary>
 /// <param name="dir">The WzDirectory to add</param>
 public void AddDirectory(WzDirectory dir)
 {
     WzDirectories.Add(dir);
     dir._wzFile = _wzFile;
     dir.Parent  = this;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Parses the WzDirectory
        /// </summary>
        internal void ParseDirectory()
        {
            var entryCount = _reader.ReadCompressedInt();

            for (var i = 0; i < entryCount; i++)
            {
                var    type  = _reader.ReadByte();
                string fname = null;

                long rememberPos = 0;

                switch (type)
                {
                case 1:
                    var unknown = _reader.ReadInt32();
                    _reader.ReadInt16();
                    var offs = _reader.ReadOffset();
                    continue;

                case 2:
                    var stringOffset = _reader.ReadInt32();
                    rememberPos = _reader.BaseStream.Position;
                    _reader.BaseStream.Position = _reader.Header.FStart + stringOffset;
                    type  = _reader.ReadByte();
                    fname = _reader.ReadString();
                    break;

                case 3:
                case 4:
                    fname       = _reader.ReadString();
                    rememberPos = _reader.BaseStream.Position;
                    break;
                }

                _reader.BaseStream.Position = rememberPos;
                var fsize       = _reader.ReadCompressedInt();
                var dirChecksum = _reader.ReadCompressedInt();
                var dirOffset   = _reader.ReadOffset();
                if (type == 3)
                {
                    var subDir = new WzDirectory(_reader, fname, _hash, WzIv, _wzFile)
                    {
                        BlockSize = fsize,
                        Checksum  = dirChecksum,
                        Offset    = dirOffset,
                        Parent    = this
                    };
                    WzDirectories.Add(subDir);
                }
                else
                {
                    var img = new WzImage(fname, _reader)
                    {
                        BlockSize = fsize,
                        Checksum  = dirChecksum,
                        Offset    = dirOffset,
                        Parent    = this
                    };
                    WzImages.Add(img);
                }
            }

            foreach (var subdir in WzDirectories)
            {
                _reader.BaseStream.Position = subdir.Offset;
                subdir.ParseDirectory();
            }
        }