/// <summary> /// Creates a new EWFInfo helper class from filePath. /// </summary> /// <param name="filePath">The path of the EWF file.</param> public EWFInfo(string filePath) { FilePath = filePath; using (FileStream fs = File.OpenRead(filePath)) { fs.Seek(0, SeekOrigin.Begin); byte[] buff = new byte[13]; fs.Read(buff, 0, 13); EWFHeader ewfHeader = new EWFHeader(buff); while (fs.Position < fs.Length) { buff = new byte[76]; fs.Read(buff, 0, 76); SectionDescriptor sd = new SectionDescriptor(buff, fs.Position - 76); switch (sd.SectionType) { case SECTION_TYPE.header: case SECTION_TYPE.header2: // Save the header buff = new byte[sd.NextSectionOffset - fs.Position]; fs.Read(buff, 0, sd.NextSectionOffset - (int)fs.Position); HeaderSection = new Section.Header2(buff); break; case SECTION_TYPE.volume: case SECTION_TYPE.disk: case SECTION_TYPE.data: // Save the volume buff = new byte[sd.NextSectionOffset - fs.Position]; fs.Read(buff, 0, sd.NextSectionOffset - (int)fs.Position); VolumeSection = new Section.Volume(buff); break; case SECTION_TYPE.next: case SECTION_TYPE.done: fs.Seek(76, SeekOrigin.Current); break; default: fs.Seek(sd.NextSectionOffset - (int)fs.Position, SeekOrigin.Current); break; } if (HeaderSection != null && VolumeSection != null) { break; } } } if (HeaderSection == null || VolumeSection == null) { throw new Exception("file missing header or volume section"); } }
/// <summary> /// Creates a new EWFInfo helper class from filePath. /// </summary> /// <param name="filePath">The path of the EWF file.</param> public EWFInfo(string filePath) { FilePath = filePath; using (FileStream fs = File.OpenRead(filePath)) { fs.Seek(0, SeekOrigin.Begin); byte[] buff = new byte[13]; fs.Read(buff, 0, 13); EWFHeader ewfHeader = new EWFHeader(buff); while (fs.Position < fs.Length) { buff = new byte[76]; fs.Read(buff, 0, 76); SectionDescriptor sd = new SectionDescriptor(buff, fs.Position - 76); switch (sd.SectionType) { case SECTION_TYPE.header: case SECTION_TYPE.header2: // Save the header buff = new byte[sd.NextSectionOffset - fs.Position]; fs.Read(buff, 0, sd.NextSectionOffset - (int)fs.Position); HeaderSection = new Section.Header2(buff); break; case SECTION_TYPE.volume: case SECTION_TYPE.disk: case SECTION_TYPE.data: // Save the volume buff = new byte[sd.NextSectionOffset - fs.Position]; fs.Read(buff, 0, sd.NextSectionOffset - (int)fs.Position); VolumeSection = new Section.Volume(buff); break; case SECTION_TYPE.next: case SECTION_TYPE.done: fs.Seek(76, SeekOrigin.Current); break; default: fs.Seek(sd.NextSectionOffset - (int)fs.Position, SeekOrigin.Current); break; } if (HeaderSection != null && VolumeSection != null) break; } } if (HeaderSection == null || VolumeSection == null) throw new Exception("file missing header or volume section"); }