summaryrefslogtreecommitdiff
path: root/mythfs/service/inodes
diff options
context:
space:
mode:
Diffstat (limited to 'mythfs/service/inodes')
-rw-r--r--mythfs/service/inodes/filterByDateDirectory.cpp44
-rw-r--r--mythfs/service/inodes/filterByDateDirectory.h24
-rw-r--r--mythfs/service/inodes/groupingByDateDirectory.cpp23
-rw-r--r--mythfs/service/inodes/groupingByDateDirectory.h9
4 files changed, 97 insertions, 3 deletions
diff --git a/mythfs/service/inodes/filterByDateDirectory.cpp b/mythfs/service/inodes/filterByDateDirectory.cpp
new file mode 100644
index 0000000..ddf048c
--- /dev/null
+++ b/mythfs/service/inodes/filterByDateDirectory.cpp
@@ -0,0 +1,44 @@
+#include "filterByDateDirectory.h"
+#include "symlink.h"
+#include <buffer.h>
+#include <exceptions.h>
+#include <boost/algorithm/string/predicate.hpp>
+
+namespace MythFS {
+ FilterByDateDirectory::FilterByDateDirectory(DBPrx db, const std::string & d) :
+ FilteringDirectory<std::string>(db),
+ date(d)
+ {
+ }
+
+ std::string
+ FilterByDateDirectory::attribute(const MythFS::RecordedPtr & r) const
+ {
+ AdHoc::Buffer n;
+ n.append(r->title);
+ if (!r->subtitle.empty()) {
+ n.appendbf(": %s", r->subtitle);
+ }
+ n.append(".mpg");
+ return n;
+ }
+
+ Node::PointerType
+ FilterByDateDirectory::getChild(const std::string & n) const
+ {
+ for (auto r :db->getRecorded()) {
+ if (attribute(r) == n) {
+ return new Symlink("/var/store/mythrecordings/" + r->basename);
+ }
+ }
+ throw NetFS::SystemError(ENOENT);
+ }
+
+ bool
+ FilterByDateDirectory::matches(const MythFS::RecordedPtr & r) const
+ {
+ return boost::algorithm::starts_with(r->startTime, date);
+ }
+}
+
+
diff --git a/mythfs/service/inodes/filterByDateDirectory.h b/mythfs/service/inodes/filterByDateDirectory.h
new file mode 100644
index 0000000..84da471
--- /dev/null
+++ b/mythfs/service/inodes/filterByDateDirectory.h
@@ -0,0 +1,24 @@
+#ifndef MYTHFS_FILTERBYDATE_H
+#define MYTHFS_FILTERBYDATE_H
+
+#include "filteringDirectory.h"
+#include <myth-models.h>
+#include <myth-db.h>
+
+namespace MythFS {
+ class FilterByDateDirectory : public FilteringDirectory<std::string> {
+ public:
+ FilterByDateDirectory(DBPrx db, const std::string &);
+
+ protected:
+ std::string attribute(const MythFS::RecordedPtr &) const;
+ bool matches(const MythFS::RecordedPtr &) const;
+ PointerType getChild(const std::string &) const;
+
+ const std::string date;
+ };
+}
+
+#endif
+
+
diff --git a/mythfs/service/inodes/groupingByDateDirectory.cpp b/mythfs/service/inodes/groupingByDateDirectory.cpp
new file mode 100644
index 0000000..dccf38e
--- /dev/null
+++ b/mythfs/service/inodes/groupingByDateDirectory.cpp
@@ -0,0 +1,23 @@
+#include "groupingByDateDirectory.h"
+#include "filterByDateDirectory.h"
+
+namespace MythFS {
+ ByDateDirectory::ByDateDirectory(DBPrx db) :
+ GroupingDirectory<std::string>(db)
+ {
+ }
+
+ std::string
+ ByDateDirectory::attribute(const MythFS::RecordedPtr & r) const
+ {
+ return r->startTime.substr(0, 10);
+ }
+
+ Node::PointerType
+ ByDateDirectory::getChild(const std::string & t) const
+ {
+ return new FilterByDateDirectory(db, t);
+ }
+}
+
+
diff --git a/mythfs/service/inodes/groupingByDateDirectory.h b/mythfs/service/inodes/groupingByDateDirectory.h
index 945a9d0..1fef9e5 100644
--- a/mythfs/service/inodes/groupingByDateDirectory.h
+++ b/mythfs/service/inodes/groupingByDateDirectory.h
@@ -1,13 +1,16 @@
-#ifndef MYTHFS_BYTITLEDIRECTORY_H
-#define MYTHFS_BYTITLEDIRECTORY_H
+#ifndef MYTHFS_BYDATEDIRECTORY_H
+#define MYTHFS_BYDATEDIRECTORY_H
#include "groupingDirectory.h"
namespace MythFS {
class ByDateDirectory : public GroupingDirectory<std::string> {
+ public:
+ ByDateDirectory(DBPrx db);
protected:
- virtual std::string attribute(const MythFS::RecordedPtr &) const;
+ std::string attribute(const MythFS::RecordedPtr &) const override;
+ PointerType getChild(const std::string &) const override;
};
}