Be a bit more careful with fwrite.
[dcpomatic.git] / src / lib / reel_writer.cc
index 9a600a739b8fc59d5a3ccd727e102a54a15bea16..e34874a14ca91c7bed111c0c8759fcdb368d21d1 100644 (file)
@@ -23,6 +23,7 @@
 #include "cross.h"
 #include "job.h"
 #include "log.h"
+#include "dcpomatic_log.h"
 #include "digester.h"
 #include "font.h"
 #include "compose.hpp"
 
 #include "i18n.h"
 
-#define LOG_GENERAL(...) _film->log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL);
-#define LOG_GENERAL_NC(...) _film->log()->log (__VA_ARGS__, LogEntry::TYPE_GENERAL);
-#define LOG_WARNING_NC(...) _film->log()->log (__VA_ARGS__, LogEntry::TYPE_WARNING);
-#define LOG_ERROR(...) _film->log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_ERROR);
-
 using std::list;
 using std::string;
 using std::cout;
@@ -147,9 +143,9 @@ ReelWriter::write_frame_info (Frame frame, Eyes eyes, dcp::FrameInfo info) const
                throw OpenFileError (info_file, errno, read);
        }
        dcpomatic_fseek (file, frame_info_position (frame, eyes), SEEK_SET);
-       fwrite (&info.offset, sizeof (info.offset), 1, file);
-       fwrite (&info.size, sizeof (info.size), 1, file);
-       fwrite (info.hash.c_str(), 1, info.hash.size(), file);
+       checked_fwrite (&info.offset, sizeof (info.offset), file, info_file);
+       checked_fwrite (&info.size, sizeof (info.size), file, info_file);
+       checked_fwrite (info.hash.c_str(), info.hash.size(), file, info_file);
        fclose (file);
 }
 
@@ -158,11 +154,11 @@ ReelWriter::read_frame_info (FILE* file, Frame frame, Eyes eyes) const
 {
        dcp::FrameInfo info;
        dcpomatic_fseek (file, frame_info_position (frame, eyes), SEEK_SET);
-       fread (&info.offset, sizeof (info.offset), 1, file);
-       fread (&info.size, sizeof (info.size), 1, file);
+       checked_fread (&info.offset, sizeof(info.offset), file, _film->info_file(_period));
+       checked_fread (&info.size, sizeof(info.size), file, _film->info_file(_period));
 
        char hash_buffer[33];
-       fread (hash_buffer, 1, 32, file);
+       checked_fread (hash_buffer, 32, file, _film->info_file(_period));
        hash_buffer[32] = '\0';
        info.hash = hash_buffer;