summaryrefslogtreecommitdiff
path: root/src/lib/content.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-07-24 10:32:52 +0100
committerCarl Hetherington <cth@carlh.net>2013-07-24 10:32:52 +0100
commit49a51ff9778f3b72ee962d3e8bd9cf71944f3c2b (patch)
tree2b916b15eabd8132bbc80b00e4a4f09edfd9eb92 /src/lib/content.cc
parent084d5155d410eef68f87635876e136b224db91dc (diff)
Rename Content::_file to path and support md5sums of directories.
Diffstat (limited to 'src/lib/content.cc')
-rw-r--r--src/lib/content.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/lib/content.cc b/src/lib/content.cc
index 0db93d5e3..372be3020 100644
--- a/src/lib/content.cc
+++ b/src/lib/content.cc
@@ -43,7 +43,7 @@ Content::Content (shared_ptr<const Film> f, Time s)
Content::Content (shared_ptr<const Film> f, boost::filesystem::path p)
: _film (f)
- , _file (p)
+ , _path (p)
, _start (0)
, _change_signals_frequent (false)
{
@@ -54,7 +54,7 @@ Content::Content (shared_ptr<const Film> f, shared_ptr<const cxml::Node> node)
: _film (f)
, _change_signals_frequent (false)
{
- _file = node->string_child ("File");
+ _path = node->string_child ("Path");
_digest = node->string_child ("Digest");
_start = node->number_child<Time> ("Start");
}
@@ -63,7 +63,7 @@ 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("Path")->add_child_text (_path.string());
node->add_child("Digest")->add_child_text (_digest);
node->add_child("Start")->add_child_text (lexical_cast<string> (_start));
}
@@ -71,7 +71,13 @@ Content::as_xml (xmlpp::Node* node) const
void
Content::examine (shared_ptr<Job>)
{
- string const d = md5_digest (_file);
+ string d;
+ if (boost::filesystem::is_regular_file (_path)) {
+ d = md5_digest (_path);
+ } else {
+ d = md5_digest_directory (_path);
+ }
+
boost::mutex::scoped_lock lm (_mutex);
_digest = d;
}
@@ -113,5 +119,5 @@ Content::clone () const
string
Content::technical_summary () const
{
- return String::compose ("%1 %2 %3", file(), digest(), start());
+ return String::compose ("%1 %2 %3", path(), digest(), start());
}