- auto const chain = Config::instance()->decryption_chain()->chain();
- checked_fwrite (chain.c_str(), chain.length(), f, path);
- optional<string> const key = Config::instance()->decryption_chain()->key();
- DCPOMATIC_ASSERT (key);
- checked_fwrite (key->c_str(), key->length(), f, path);
- fclose (f);
+ boost::filesystem::path path(wx_to_std(d->GetPath()));
+ dcp::File f(path, "w");
+ if (!f) {
+ throw OpenFileError(path, errno, OpenFileError::WRITE);