summaryrefslogtreecommitdiff
path: root/src/lib/reel_writer.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-09-29 23:28:57 +0200
committerCarl Hetherington <cth@carlh.net>2019-10-08 20:16:13 +0200
commit93e89bd463bd51de6823a6796288f6283f885b06 (patch)
tree9dd40b4023688b5624d2688eb16c23adb92b337e /src/lib/reel_writer.cc
parent7ba1a973a8d06df646961c11dc34f73bd7141834 (diff)
Improve OpenFileError so that it doesn't say "opening for read"
in one case where it should say "opening for read/write". Also add some unit tests for ReelWriter.
Diffstat (limited to 'src/lib/reel_writer.cc')
-rw-r--r--src/lib/reel_writer.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc
index b7ccc07ce..355fe5c3b 100644
--- a/src/lib/reel_writer.cc
+++ b/src/lib/reel_writer.cc
@@ -62,6 +62,7 @@ using dcp::raw_convert;
int const ReelWriter::_info_size = 48;
+/** @param job Related job, or 0 */
ReelWriter::ReelWriter (
shared_ptr<const Film> film, DCPTimePeriod period, shared_ptr<Job> job, int reel_index, int reel_count, optional<string> content_summary
)
@@ -97,7 +98,9 @@ ReelWriter::ReelWriter (
_film->internal_video_asset_dir() / _film->internal_video_asset_filename(_period)
);
- job->sub (_("Checking existing image data"));
+ if (job) {
+ job->sub (_("Checking existing image data"));
+ }
_first_nonexistant_frame = check_existing_picture_asset ();
_picture_asset_writer = _picture_asset->start_write (
@@ -139,8 +142,9 @@ ReelWriter::write_frame_info (Frame frame, Eyes eyes, dcp::FrameInfo info) const
} else {
file = fopen_boost (info_file, "wb");
}
+
if (!file) {
- throw OpenFileError (info_file, errno, read);
+ throw OpenFileError (info_file, errno, read ? OpenFileError::READ_WRITE : OpenFileError::WRITE);
}
dcpomatic_fseek (file, frame_info_position (frame, eyes), SEEK_SET);
checked_fwrite (&info.offset, sizeof (info.offset), file, info_file);