summaryrefslogtreecommitdiff
path: root/src/lib/content.cc
blob: 977f2e2a78f73d1d7b47a00010010357242ef356 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <boost/thread/mutex.hpp>
#include <libxml++/libxml++.h>
#include <libcxml/cxml.h>
#include "content.h"
#include "util.h"

using std::string;
using boost::shared_ptr;

Content::Content (boost::filesystem::path f)
	: _file (f)
{

}

Content::Content (shared_ptr<const cxml::Node> node)
{
	_file = node->string_child ("File");
	_digest = node->string_child ("Digest");
}

void
Content::as_xml (xmlpp::Node* node) const
{
	boost::mutex::scoped_lock lm (_mutex);
	node->add_child("File")->add_child_text (_file.string());
	node->add_child("Digest")->add_child_text (_digest);
}

void
Content::examine (shared_ptr<Film>, shared_ptr<Job>, bool)
{
	string const d = md5_digest (_file);
	boost::mutex::scoped_lock lm (_mutex);
	_digest = d;
}