#include "audio_content.h"
#include "audio_processor.h"
#include "change_signaller.h"
-#include "check_content_change_job.h"
#include "cinema.h"
#include "compose.hpp"
#include "config.h"
/** Write state to our `metadata' file */
void
-Film::write_metadata () const
+Film::write_metadata ()
{
DCPOMATIC_ASSERT (directory());
boost::filesystem::create_directories (directory().get());
}
}
+ _last_written_by = f.optional_string_child("LastWrittenBy");
+
_name = f.string_child ("Name");
if (_state_version >= 9) {
_use_isdcf_name = f.bool_child ("UseISDCFName");
if (_ratings.empty ()) {
d += "-NR";
} else {
- d += "-" + _ratings[0].label;
+ auto label = _ratings[0].label;
+ boost::erase_all(label, "+");
+ boost::erase_all(label, "-");
+ d += "-" + label;
}
}
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) {
vector<NamedChannel> n;
for (int i = 0; i < audio_channels(); ++i) {
- if (i != 8 && i != 9 && i != 15) {
+ if (Config::instance()->use_all_audio_channels() || (i != 8 && i != 9 && i != 15)) {
n.push_back (NamedChannel(short_audio_channel_name(i), i));
}
}
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
void
-Film::set_dirty (bool dirty) const
+Film::set_dirty (bool dirty)
{
+ auto const changed = dirty != _dirty;
_dirty = dirty;
+ if (changed) {
+ emit (boost::bind(boost::ref(DirtyChange), _dirty));
+ }
+}
+
+
+/** @return true if the metadata was (probably) last written by a version earlier
+ * than the given one; false if it definitely was not.
+ */
+bool
+Film::last_written_by_earlier_than(int major, int minor, int micro) const
+{
+ if (!_last_written_by) {
+ return true;
+ }
+
+ vector<string> parts;
+ boost::split(parts, *_last_written_by, boost::is_any_of("."));
+
+ if (parts.size() != 3) {
+ /* Not sure what's going on, so let's say it was written by an old version */
+ return true;
+ }
+
+ if (boost::ends_with(parts[2], "pre")) {
+ parts[2] = parts[2].substr(0, parts[2].length() - 3);
+ }
+
+ int our_major = dcp::raw_convert<int>(parts[0]);
+ int our_minor = dcp::raw_convert<int>(parts[1]);
+ int our_micro = dcp::raw_convert<int>(parts[2]);
+
+ if (our_major != major) {
+ return our_major < major;
+ }
+
+ if (our_minor != minor) {
+ return our_minor < minor;
+ }
+
+ return our_micro < micro;
}