Esempio n. 1
0
        public WZDirectory Open()
        {
            if (!loaded)
            {
                loaded = true;

                long soffset = file.file.BaseStream.Position;

                file.file.BaseStream.Seek(baseOffset + file.FileStart, SeekOrigin.Begin);

                int count = file.ReadValue();

                for (int i = 0; i < count; i++)
                {
                    string Name = "";
                    int    size, checksum, offset;
                    byte   type = file.ReadByte();

                    switch (type)
                    {
                    case 0x02: Name = file.ReadStringAt(true); break;

                    case 0x03:
                    case 0x04: Name = file.ReadString(); break;
                    }

                    size     = file.ReadValue();
                    checksum = file.ReadValue();
                    offset   = file.ReadOffset();

                    switch (type)
                    {
                    case 0x02:
                    case 0x04: IMGs.Add(Name, new IMGFile(Name, file, offset, this, size, checksum)); break;

                    case 0x03: Directories.Add(Name, new WZDirectory(Name, file, offset, this, size)); break;
                    }
                }

                file.file.BaseStream.Seek(soffset, SeekOrigin.Begin);
            }
            return(this);
        }