Various fixes.
[dcpomatic.git] / src / lib / content.cc
1 #include <boost/thread/mutex.hpp>
2 #include <libxml++/libxml++.h>
3 #include <libcxml/cxml.h>
4 #include "content.h"
5 #include "util.h"
6
7 using std::string;
8 using boost::shared_ptr;
9
10 Content::Content (boost::filesystem::path f)
11         : _file (f)
12 {
13
14 }
15
16 Content::Content (shared_ptr<const cxml::Node> node)
17 {
18         _file = node->string_child ("File");
19         _digest = node->string_child ("Digest");
20 }
21
22 Content::Content (Content const & o)
23         : _file (o._file)
24         , _digest (o._digest)
25 {
26
27 }
28
29 void
30 Content::as_xml (xmlpp::Node* node) const
31 {
32         boost::mutex::scoped_lock lm (_mutex);
33         node->add_child("File")->add_child_text (_file.string());
34         node->add_child("Digest")->add_child_text (_digest);
35 }
36
37 void
38 Content::examine (shared_ptr<Film>, shared_ptr<Job>, bool)
39 {
40         string const d = md5_digest (_file);
41         boost::mutex::scoped_lock lm (_mutex);
42         _digest = d;
43 }