public void Copy(FileImageEntryBase fimgEntry) { ReadFrom(new BinaryReader(new ByteArrayStream(fimgEntry.File))); }
public FIMGFrame(BinaryReader brrReader, int nSize, params object[] args) { FATBFrame fatbFrame = (FATBFrame)args[0]; if (nSize < 0 || nSize > 0 && fatbFrame.FilesCount == 0) { throw new FormatException(); } m_lstfimgeEntries = new List <FileImageEntryBase>(fatbFrame.FilesCount); int position = (int)brrReader.BaseStream.Position; int num = 0; int tempNum = 0; foreach (FATBFrame.FileAllocationTableEntry entry in fatbFrame.Entries) { tempNum++; //if (tempNum > 4) break; if (entry.Start != brrReader.BaseStream.Position - position) { throw new FormatException(); } FileImageEntryBase fileImageEntryBase = null; foreach (byte readByte in brrReader.ReadBytes(4)) { if (readByte < 65 || readByte > 90) { brrReader.BaseStream.Position -= 4L; m_lstfimgeEntries.Add(fileImageEntryBase = SimpleFileImageEntry.ReadFrom(brrReader, entry.End - entry.Start, ref nSize)); break; } } if (fileImageEntryBase == null) { brrReader.ReadInt32(); bool flag = brrReader.ReadInt32() > brrReader.BaseStream.Length - brrReader.BaseStream.Position + 12L; brrReader.BaseStream.Position -= 12L; try { if (flag) { m_lstfimgeEntries.Add(fileImageEntryBase = SimpleFileImageEntry.ReadFrom(brrReader, entry.End - entry.Start, ref nSize)); } else { m_lstfimgeEntries.Add(fileImageEntryBase = NitroFileBase.ReadFrom(brrReader, entry.End - entry.Start, ref nSize)); } } catch { try { if (flag) { m_lstfimgeEntries.Add(fileImageEntryBase = SimpleFileImageEntry.ReadFrom(brrReader, entry.End - entry.Start - 2, ref nSize)); } else { m_lstfimgeEntries.Add(fileImageEntryBase = NitroFileBase.ReadFrom(brrReader, entry.End - entry.Start - 2, ref nSize)); } } catch { } } ++num; } fileImageEntryBase.Changed += new FileImageEntryBase.FileChanged(entry.FileChanged); while ((brrReader.BaseStream.Position - position) % 4L != 0L) { if (brrReader.ReadByte() != byte.MaxValue) { throw new FormatException(); } --nSize; } } /*if (nSize != 0) * throw new FormatException();*/ //this.Entries[3] = this.Entries[2]; }