public void ReadFile(BinaryReader br) { MpkFileHeader header = new MpkFileHeader(); header.Read(br); switch (header.VersionString) { case "Version 1.0": readV1(br, header); break; } ReadFile(br); }
private void readV1(BinaryReader br,MpkFileHeader header) { ArrayList files = new ArrayList(); foreach(int size in header.Sizes) { ArrayList chars = new ArrayList(); char ch; while((ch=br.ReadChar())!='\0') chars.Add(ch); byte[] data = br.ReadBytes(size); IMpkEntry ime = IMpkEntry.GetType((MpkEntryType)br.ReadByte()); ime.Data=data; ime.FileName=new string((char[])chars.ToArray(typeof(char))); files.Add(ime); } }
public void WriteFile(BinaryWriter bw) { MpkFileHeader header = new MpkFileHeader(); ArrayList entries = new ArrayList(); //... put all IMpkEntries into arraylist header.Entries=entries; header.Write(bw); bw.Flush(); foreach(IMpkEntry imp in entries) { bw.Write(imp.FileName.ToCharArray()); bw.Write((char)'\0'); bw.Write((byte)imp.Type); bw.Write(imp.Data); bw.Flush(); } }
public void WriteFile(BinaryWriter bw) { MpkFileHeader header = new MpkFileHeader(); ArrayList entries = new ArrayList(); //... put all IMpkEntries into arraylist header.Entries = entries; header.Write(bw); bw.Flush(); foreach (IMpkEntry imp in entries) { bw.Write(imp.FileName.ToCharArray()); bw.Write((char)'\0'); bw.Write((byte)imp.Type); bw.Write(imp.Data); bw.Flush(); } }
private void readV1(BinaryReader br, MpkFileHeader header) { ArrayList files = new ArrayList(); foreach (int size in header.Sizes) { ArrayList chars = new ArrayList(); char ch; while ((ch = br.ReadChar()) != '\0') { chars.Add(ch); } byte[] data = br.ReadBytes(size); IMpkEntry ime = IMpkEntry.GetType((MpkEntryType)br.ReadByte()); ime.Data = data; ime.FileName = new string((char[])chars.ToArray(typeof(char))); files.Add(ime); } }
public void ReadFile(BinaryReader br) { MpkFileHeader header = new MpkFileHeader(); header.Read(br); switch(header.VersionString) { case "Version 1.0": readV1(br,header); break; } ReadFile(br); }