/// <summary> 使用外部的<see cref="WzFileStream"/>讀取資料 </summary> public bool Read(WzFileStream zs) { string identifier = zs.ReadString(4); if (!identifier.Equals("PKG1")) { return(false); } this.DataSize = zs.Read8(); this.DataOffset = zs.Read4u(); this.Description = zs.ReadString((int)(this.DataOffset - zs.Tell())); zs.BaseOffset = this.DataOffset; ushort cryptedHash = zs.Read2u(); this.RootDirectory.Offset = (uint)zs.Tell(); for (int j = 0; j < 0xFFFF; j++) { this.Hash = HashTools.GenerateArchiveVersionHash(j.ToString()); if (HashTools.EncryptArchiveVersionHash(this.Hash) == cryptedHash) { zs.StringPool.Clear(); if (this.RootDirectory.Read(zs)) { this.Version = j; return(true); } } } return(false); }
/// <summary> 從指定資料流讀取腳本資料 </summary> public bool Read(WzFileStream stream) { stream.Seek(0, true); byte flag = stream.Read1u(); switch (flag) { case 1: int len = stream.Read4(true); this.Script = stream.ReadString(len, Encoding.UTF8, true); break; default: throw new NotSupportedException("Not supported flag : " + flag); } return(true); }