internal void Write(WzFileStream stream) { stream.Write(this.majortype.ToByteArray()); stream.Write(this.subtype.ToByteArray()); stream.Write1u(this.Unknow1_Byte); stream.Write1u(this.Unknow2_Byte); stream.Write(this.formattype.ToByteArray()); if (this.formattype == SoundDX8Constants.WMFORMAT_WaveFormatEx) { stream.Write4((int)this.cbFormat, true); stream.Write(this.pbFormat); } }
/// <summary> 將文字寫入指定的<see cref="WzFileStream"/>中 </summary> public static void Write(WzFileStream stream, string str) { int len = str.Length; bool uni = false; foreach (char ch in str) { if ((int)ch > 0xFF) { uni = true; break; } } byte[] chars = (uni ? Encoding.Unicode : Encoding.ASCII).GetBytes(str); Process(chars, len, uni); if ((uni && len <= 127) || (!uni && len <= 128)) { stream.Write1((sbyte)(uni ? len : -len)); } else { stream.Write1u((byte)(uni ? 0x7F : 0x80)); stream.Write4(len); } stream.Write(chars, true); }
/// <summary> 使用外部的的<see cref="WzFileStream"/>儲存資料 </summary> public bool Write(WzFileStream zs) { this.Hash = HashTools.GenerateArchiveVersionHash(this.Version.ToString()); // header zs.Write(new byte[] { (byte)'P', (byte)'K', (byte)'G', (byte)'1' }, 4); zs.Write8(0); //Reserve zs.Write4u(0); //Reserve zs.WriteString(this.Description); // data long off = zs.Tell(); this.DataOffset = (uint)off; zs.BaseOffset = this.DataOffset; zs.Write2u((ushort)HashTools.EncryptArchiveVersionHash(this.Hash)); this.RootDirectory.Update(); this.RootDirectory.Write(zs); long endoff = zs.Tell(); // rewrite size, offset zs.Seek(4); zs.Write8(endoff - off); zs.Write4u((uint)off); // end write zs.Flush(); return(true); }
/// <summary> 將腳本資料寫入指定資料流 </summary> public bool Write(WzFileStream stream) { byte[] data = Encoding.UTF8.GetBytes(this.Script); stream.Write1u(1); stream.Write4(data.Length, true); stream.Write(data, data.Length, true); return(true); }
internal override bool Write(WzFileStream stream) { stream.Write1u(this.Unknow1_Byte); stream.Write4(this.mSoundData.Length, true); stream.Write4(this.Duration, true); stream.Write1u(this.Unknow3_Byte); this.MediaType.Write(stream); stream.Write(this.mSoundData); return(true); }
internal override bool Write(WzFileStream stream) { bool hasprop = this.CanvasProperty.Count > 0; stream.Write1u(this.Unknow1_Byte); stream.WriteBool(hasprop); if (hasprop) { this.CanvasProperty.Write(stream); } stream.Write4(this.Width, true); stream.Write4(this.Height, true); stream.Write4((int)this.Format, true); stream.Write1u(this.Scale); stream.Write4(this.Unknow2_Int); stream.Write4(this.mCanvasData.Length); stream.Write(this.mCanvasData); return(true); }