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;
    }
}
Example #2
0
System* MolecularFileDialog::openXYZFile()
{
	return openFile_("XYZ");
}
Example #3
0
System* MolecularFileDialog::openACFile()
{
	return openFile_("AC");
}
Example #4
0
System* MolecularFileDialog::openSDFile()
{
	return openFile_("SDF");
}
Example #5
0
System* MolecularFileDialog::openMOL2File()
{
	return openFile_("MOL2");
}
Example #6
0
System* MolecularFileDialog::openHINFile()
{
	return openFile_("HIN");
}
Example #7
0
System* MolecularFileDialog::openPDBFile()
{
	return openFile_("PDB");
}