#include "cinema.h"
#include "util.h"
#include "cross.h"
+#include "film.h"
#include <dcp/raw_convert.h>
#include <dcp/name_format.h>
#include <dcp/colour_matrix.h>
void
Config::save_template (shared_ptr<const Film> film, string name) const
{
- boost::filesystem::create_directories (path ("templates"));
- shared_ptr<xmlpp::Document> doc = film->metadata (false);
- doc->write_to_file_formatted (path("templates") / tidy_for_filename (name));
+ film->write_template (template_path (name));
+}
+
+list<string>
+Config::templates () const
+{
+ list<string> n;
+ for (boost::filesystem::directory_iterator i (path("templates")); i != boost::filesystem::directory_iterator(); ++i) {
+ n.push_back (i->path().filename().string());
+ }
+ return n;
+}
+
+bool
+Config::existing_template (string name) const
+{
+ return boost::filesystem::exists (template_path (name));
+}
+
+boost::filesystem::path
+Config::template_path (string name) const
+{
+ return path("templates") / tidy_for_filename (name);
+}
+
+void
+Config::rename_template (string old_name, string new_name) const
+{
+ boost::filesystem::rename (template_path (old_name), template_path (new_name));
+}
+
+void
+Config::delete_template (string name) const
+{
+ boost::filesystem::remove (template_path (name));
}