void ReadMobiFile(MobiHeaderReader mobiReader, PdbRecords pdbRecords) { string title = mobiReader.GetTitleReader().ReadTitle(); ExthHeaderReader exthReader = mobiReader.GetExthHeaderReader(); if (exthReader == null) { _mobiFile = MakeMobiFileNoExth(title); } else { _mobiFile = MakeMobiFromExth(exthReader, title); } }
void ReadExth(Action<MobiHeaderReader, PdbRecords> exthHandler) { if (!File.Exists(_filepath)) throw new FileNotFoundException(string.Format("Cannot find file '{0}'", _filepath)); using (var file = new FileStream(_filepath, FileMode.Open)) { using (var binary = new BinaryReader(file)) { PdbRecords pdbRecords = ObtainPdbRecords(binary); binary.BaseStream.Position = pdbRecords.GetRecordOffset(0); var mobiReader = new MobiHeaderReader(binary); exthHandler(mobiReader, pdbRecords); } } }