using std::runtime_error;
/** @param f File that we were trying to open */
-OpenFileError::OpenFileError (boost::filesystem::path f)
- : FileError (String::compose (_("could not open file %1"), f.string()), f)
-{
-
-}
-
-/** @param f File that we were trying to create */
-CreateFileError::CreateFileError (boost::filesystem::path f)
- : FileError (String::compose (_("could not create file %1"), f.string()), f)
+OpenFileError::OpenFileError (boost::filesystem::path f, int error)
+ : FileError (String::compose (_("could not open file %1 (%2)"), f.string(), error), f)
{
}
{
public:
/** @param f File that we were trying to open */
- OpenFileError (boost::filesystem::path f);
+ OpenFileError (boost::filesystem::path f, int error);
};
-/** @class CreateFileError.
- * @brief Indicates that some error occurred when trying to create a file.
- */
-class CreateFileError : public FileError
-{
-public:
- /** @param f File that we were trying to create */
- CreateFileError (boost::filesystem::path f);
-};
-
-
/** @class ReadFileError.
* @brief Indicates that some error occurred when trying to read from a file
*/
av_dict_set (&options, "analyzeduration", raw_convert<string> (5 * 60 * 1000000).c_str(), 0);
av_dict_set (&options, "probesize", raw_convert<string> (5 * 60 * 1000000).c_str(), 0);
- if (avformat_open_input (&_format_context, 0, 0, &options) < 0) {
- throw OpenFileError (_ffmpeg_content->path(0).string ());
+ int e = avformat_open_input (&_format_context, 0, 0, &options);
+ if (e < 0) {
+ throw OpenFileError (_ffmpeg_content->path(0).string(), e);
}
if (avformat_find_stream_info (_format_context, 0) < 0) {
_current_path = p;
_current_file = fopen_boost (_paths[_current_path], "rb");
if (_current_file == 0) {
- throw OpenFileError (_paths[_current_path]);
+ throw OpenFileError (_paths[_current_path], errno);
}
}
boost::uintmax_t const size = boost::filesystem::file_size (path);
FILE* f = fopen_boost (path, "rb");
if (!f) {
- throw OpenFileError (path);
+ throw OpenFileError (path, errno);
}
uint8_t* data = new uint8_t[size];
file = fopen_boost (info_file, "wb");
}
if (!file) {
- throw OpenFileError (info_file);
+ throw OpenFileError (info_file, errno);
}
dcpomatic_fseek (file, frame_info_position (frame, eyes), SEEK_SET);
fwrite (&info.offset, sizeof (info.offset), 1, file);
while (i < int64_t (files.size()) && to_do > 0) {
FILE* f = fopen_boost (files[i], "rb");
if (!f) {
- throw OpenFileError (files[i].string());
+ throw OpenFileError (files[i].string(), errno);
}
boost::uintmax_t this_time = min (to_do, boost::filesystem::file_size (files[i]));
while (i >= 0 && to_do > 0) {
FILE* f = fopen_boost (files[i], "rb");
if (!f) {
- throw OpenFileError (files[i].string());
+ throw OpenFileError (files[i].string(), errno);
}
boost::uintmax_t this_time = min (to_do, boost::filesystem::file_size (files[i]));
if (d->ShowModal () == wxID_OK) {
FILE* f = fopen_boost (wx_to_std (d->GetPath ()), "w");
if (!f) {
- throw OpenFileError (wx_to_std (d->GetPath ()));
+ throw OpenFileError (wx_to_std (d->GetPath ()), errno);
}
string const s = j->certificate (true);
if (d->ShowModal () == wxID_OK) {
FILE* f = fopen_boost (wx_to_std (d->GetPath ()), "w");
if (!f) {
- throw OpenFileError (wx_to_std (d->GetPath ()));
+ throw OpenFileError (wx_to_std (d->GetPath ()), errno);
}
string const s = _chain->key().get ();
if (d->ShowModal () == wxID_OK) {
FILE* f = fopen_boost (wx_to_std (d->GetPath ()), "w");
if (!f) {
- throw OpenFileError (wx_to_std (d->GetPath ()));
+ throw OpenFileError (wx_to_std (d->GetPath ()), errno);
}
string const s = Config::instance()->decryption_chain()->leaf().certificate (true);
if (d->ShowModal () == wxID_OK) {
FILE* f = fopen_boost (wx_to_std (d->GetPath ()), "w");
if (!f) {
- throw OpenFileError (wx_to_std (d->GetPath ()));
+ throw OpenFileError (wx_to_std (d->GetPath ()), errno);
}
string const s = Config::instance()->decryption_chain()->chain();