using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Fire.Container.Exception; using System.IO; namespace System.Fire.Container { public partial class ContainerList { private void LoadVersion_0101(BinaryReader br) { byte[] buffer_nameLen = new byte[1]; br.Read(buffer_nameLen, 0, 1); byte[] buffer_name = new byte[buffer_nameLen[0]]; br.Read(buffer_name, 0, buffer_nameLen[0]); this._containerName = System.Text.ASCIIEncoding.ASCII.GetString(buffer_name); byte[] buffer_groupCount = new byte[1]; br.Read(buffer_groupCount, 0, 1); for (int i = 0; i < buffer_groupCount[0]; i++) { byte[] buffer_containerCount = new byte[1]; br.Read(buffer_containerCount, 0, 1); this._container.Add(new List()); for (int j = 0; j < buffer_containerCount[0]; j++) { this._container[i].Add(new Container((byte)i, (byte)j, this._path + i + "\\" + j + ".cnt")); } } } private void LoadFileVersion_0101(BinaryReader br) { int fileCount = br.ReadInt32(); for (int i = 0, c = fileCount; i < c; i++) { long size = br.ReadInt64(); long ticks = br.ReadInt64(); byte flags = br.ReadByte(); byte mediaType = br.ReadByte(); long FileInfoPos = br.ReadInt64(); long ChunkPos = br.ReadInt64(); int ChunkLen = br.ReadInt32(); ContainerFile cf = new ContainerFile(); cf.Size = size; cf.UploadDate = new DateTime(ticks); cf.Deleted = (flags | 1) == 1; cf.MediaType = (Mime.eMediaType)mediaType; cf.FileInfoPos = FileInfoPos; cf.ChunkPos = ChunkPos; cf.ChunkLen = ChunkLen; this._files.Add(cf); } } private bool SaveVersion_0101(BinaryWriter bw) { bw.Write(Version); // Version 0x0101 if (this._containerName == null) { bw.Write((byte)0); } else { byte[] xname = System.Text.ASCIIEncoding.ASCII.GetBytes(this._containerName); bw.Write((byte)xname.Length); bw.Write(xname); } bw.Write((byte)this._container.Count); for (int i = 0; i < this._container.Count; i++) { bw.Write((byte)this._container[i].Count); } return true; } private bool SaveFileVersion_0101(BinaryWriter bw) { bw.Write(Version); /* private long _size; // 8 private DateTime _uploadDate; // 8 private bool bDeleted; // 1 private Mime.eMediaType _mediaType = Mime.eMediaType.Unknown; // 8 private long _fileInfoPos; // 8 private long _chunkPos; // 8 private int _chunkLen; // 4 */ // Version 0x0101 bw.Write(this._files.Count); for (int i = 0; i < this._files.Count; i++) { byte flag = 0; if (this._files[i].Deleted) flag |= 1; bw.Write(this._files[i].Size); bw.Write(this._files[i].UploadDate.Ticks); bw.Write(flag); bw.Write((byte)this._files[i].MediaType); bw.Write(this._files[i].FileInfoPos); bw.Write(this._files[i].ChunkPos); bw.Write(this._files[i].ChunkLen); System.Diagnostics.Debug.WriteLine(this._files[i].ToString()); } return true; } } public partial class ContainerKeyList { private bool LoadVersion_0101(BinaryReader br) { this._k = new Dictionary(); int count = br.ReadInt32(); for (int i = 0; i < count; i++) { int pos = br.ReadInt32(); int length = br.ReadInt32(); byte[] b = br.ReadBytes(length); this._k.Add(pos, new ContainerKey(b)); } return true; } private bool SaveVersion_0101(BinaryWriter bw) { bw.Write(this.Version); bw.Write(this._k.Count()); foreach (KeyValuePair kvp in this._k) { bw.Write(kvp.Key); bw.Write(kvp.Value.Length); bw.Write(kvp.Value.Key); } return true; } } }