void NamedLogWriter::open_( const boost::filesystem::path &path, const bool append) { if (hasOutput()) { BOOST_THROW_EXCEPTION(OpenedWriterError() << OpenedWriterError::Path(path_)); } try { path_ = path; if (append) { auto input = detail::openFileReadOnly(path_); boost::uuids::uuid format; detail::readFormatMagic(*input, format); if (format != MAGIC_FORMAT) { BOOST_THROW_EXCEPTION(IncompatibleFormatError() << IncompatibleFormatError::Format(format)); } auto logReader = detail::make_unique<LogReader>(std::move(input)); if (logReader->messageTypePool().header() != pool_.header()) { BOOST_THROW_EXCEPTION(IncompatibleHeaderError()); } logReader->fastCheck(); } setOutput(openFile_(path_, append)); if (append) { writeContinue(); } else { try { write(nullptr, *headerData_); } catch (std::exception &) { BOOST_THROW_EXCEPTION(UnableToWriteHeaderError() << enable_nested_current()); } } } catch (std::exception &) { if (boost::exception *const e = boost::current_exception_cast<boost::exception>()) { *e << Error::Path(path_); } state_ = State::kBad; try { closeOutput(); } catch (std::exception &) {} throw; } }
System* MolecularFileDialog::openXYZFile() { return openFile_("XYZ"); }
System* MolecularFileDialog::openACFile() { return openFile_("AC"); }
System* MolecularFileDialog::openSDFile() { return openFile_("SDF"); }
System* MolecularFileDialog::openMOL2File() { return openFile_("MOL2"); }
System* MolecularFileDialog::openHINFile() { return openFile_("HIN"); }
System* MolecularFileDialog::openPDBFile() { return openFile_("PDB"); }