void
Film::write_metadata () const
{
- std::string const dir = directory ();
-
boost::mutex::scoped_lock lm (_state_mutex);
- boost::filesystem::create_directories (dir);
+ boost::filesystem::create_directories (directory());
- string const m = file_locked ("metadata");
+ string const m = file ("metadata");
ofstream f (m.c_str ());
if (!f.good ()) {
throw CreateFileError (m);
{
boost::mutex::scoped_lock lm (_state_mutex);
- ifstream f (file_locked("metadata").c_str());
+ ifstream f (file ("metadata").c_str());
multimap<string, string> kv = read_key_value (f);
for (multimap<string, string>::const_iterator i = kv.begin(); i != kv.end(); ++i) {
string const k = i->first;
if (k == "thumb") {
int const n = atoi (v.c_str ());
/* Only add it to the list if it still exists */
- if (boost::filesystem::exists (thumb_file_for_frame_locked (n))) {
+ if (boost::filesystem::exists (thumb_file_for_frame (n))) {
_thumbs.push_back (n);
}
} else if (k == "width") {
return thumb_base_for_frame(n) + ".png";
}
-string
-Film::thumb_file_for_frame_locked (int n) const
-{
- return thumb_base_for_frame_locked(n) + ".png";
-}
-
string
Film::thumb_base (int n) const
{
Film::thumb_base_for_frame (int n) const
{
boost::mutex::scoped_lock lm (_state_mutex);
- return thumb_base_for_frame_locked (n);
-}
-string
-Film::thumb_base_for_frame_locked (int n) const
-{
stringstream s;
s.width (8);
s << setfill('0') << n;
boost::filesystem::path p;
- p /= dir_locked ("thumbs");
+ p /= dir ("thumbs");
p /= s.str ();
return p.string ();
string
Film::dir (string d) const
{
- boost::mutex::scoped_lock lm (_state_mutex);
- return dir_locked (d);
-}
-
-string
-Film::dir_locked (string d) const
-{
+ boost::mutex::scoped_lock lm (_directory_mutex);
boost::filesystem::path p;
p /= _directory;
p /= d;
return p.string ();
}
-/** Given a file or directory name, return its full path within the Film's directory */
+/** Given a file or directory name, return its full path within the Film's directory.
+ * _directory_mutex must not be locked on entry.
+ */
string
Film::file (string f) const
{
- boost::mutex::scoped_lock lm (_state_mutex);
- return file_locked (f);
-}
-
-string
-Film::file_locked (string f) const
-{
+ boost::mutex::scoped_lock lm (_directory_mutex);
boost::filesystem::path p;
p /= _directory;
p /= f;
return _content;
}
- return file_locked (_content);
+ return file (_content);
}
ContentType
/* GET */
std::string directory () const {
- boost::mutex::scoped_lock lm (_state_mutex);
+ boost::mutex::scoped_lock lm (_directory_mutex);
return _directory;
}
boost::shared_ptr<ExamineContentJob> _examine_content_job;
std::string thumb_file_for_frame (int) const;
- std::string thumb_file_for_frame_locked (int) const;
std::string thumb_base_for_frame (int) const;
- std::string thumb_base_for_frame_locked (int) const;
void signal_changed (Property);
- std::string file_locked (std::string) const;
- std::string dir_locked (std::string d) const;
void examine_content_finished ();
/** Complete path to directory containing the film metadata;
* must not be relative.
*/
std::string _directory;
+ /** Mutex for _directory */
+ mutable boost::mutex _directory_mutex;
+
/** Name for DVD-o-matic */
std::string _name;
/** True if a auto-generated DCI-compliant name should be used for our DCP */
mutable bool _dirty;
+ /** Mutex for all state except _directory */
mutable boost::mutex _state_mutex;
friend class paths_test;