/** Write state to our `metadata' file */
void
-Film::write_metadata () const
+Film::write_metadata ()
{
DCPOMATIC_ASSERT (directory());
boost::filesystem::create_directories (directory().get());
metadata()->write_to_file_formatted(file(metadata_file).string());
- _dirty = false;
+ set_dirty (false);
}
/** Write a template from this film */
set_backtrace_file (file ("backtrace.txt"));
}
- _dirty = false;
+ set_dirty (false);
return notes;
}
Film::set_directory (boost::filesystem::path d)
{
_directory = d;
- _dirty = true;
+ set_dirty (true);
}
void
Film::signal_change (ChangeType type, Property p)
{
if (type == ChangeType::DONE) {
- _dirty = true;
+ set_dirty (true);
if (p == Property::CONTENT) {
if (!_user_explicit_video_frame_rate) {
ContentChange (type, c, p, frequent);
}
- _dirty = true;
+ set_dirty (true);
}
void
check_settings_consistency ();
}
- _dirty = true;
+ set_dirty (true);
}
/** Check for (and if necessary fix) impossible settings combinations, like
boost::filesystem::path test = internal_video_asset_dir() / "test";
boost::filesystem::path test2 = internal_video_asset_dir() / "test2";
can_hard_link = true;
- auto f = fopen_boost (test, "w");
+ dcp::File f(test, "w");
if (f) {
- fclose (f);
+ f.close();
boost::system::error_code ec;
boost::filesystem::create_hard_link (test, test2, ec);
if (ec) {
return std::make_shared<InfoFileHandle>(_info_file_mutex, info_file(period), read);
}
-InfoFileHandle::InfoFileHandle (boost::mutex& mutex, boost::filesystem::path file, bool read)
+InfoFileHandle::InfoFileHandle (boost::mutex& mutex, boost::filesystem::path path, bool read)
: _lock (mutex)
- , _file (file)
+ , _file (path, read ? "rb" : (boost::filesystem::exists(path) ? "r+b" : "wb"))
{
- if (read) {
- _handle = fopen_boost (file, "rb");
- if (!_handle) {
- throw OpenFileError (file, errno, OpenFileError::READ);
- }
- } else {
- auto const exists = boost::filesystem::exists (file);
- if (exists) {
- _handle = fopen_boost (file, "r+b");
- } else {
- _handle = fopen_boost (file, "wb");
- }
-
- if (!_handle) {
- throw OpenFileError (file, errno, exists ? OpenFileError::READ_WRITE : OpenFileError::WRITE);
- }
+ if (!_file) {
+ throw OpenFileError (path, errno, read ? OpenFileError::READ : (boost::filesystem::exists(path) ? OpenFileError::READ_WRITE : OpenFileError::WRITE));
}
}
-InfoFileHandle::~InfoFileHandle ()
-{
- fclose (_handle);
-}
-
/** Add FFOC and LFOC markers to a list if they are not already there */
void
_sign_language_video_language = lang;
}
+
+void
+Film::set_dirty (bool dirty)
+{
+ auto const changed = dirty != _dirty;
+ _dirty = dirty;
+ if (changed) {
+ emit (boost::bind(boost::ref(DirtyChange), _dirty));
+ }
+}
+