+Config::have_existing (string file)
+{
+ return boost::filesystem::exists (path (file, false));
+}
+
+void
+Config::read_cinemas (cxml::Document const & f)
+{
+ _cinemas.clear ();
+ list<cxml::NodePtr> cin = f.node_children ("Cinema");
+ BOOST_FOREACH (cxml::ConstNodePtr i, f.node_children("Cinema")) {
+ /* Slightly grotty two-part construction of Cinema here so that we can use
+ shared_from_this.
+ */
+ shared_ptr<Cinema> cinema (new Cinema (i));
+ cinema->read_screens (i);
+ _cinemas.push_back (cinema);
+ }
+}
+
+void
+Config::set_cinemas_file (boost::filesystem::path file)
+{
+ _cinemas_file = file;
+
+ if (boost::filesystem::exists (_cinemas_file)) {
+ /* Existing file; read it in */
+ cxml::Document f ("Cinemas");
+ f.read_file (_cinemas_file);
+ read_cinemas (f);
+ }
+
+ changed (OTHER);
+}
+
+void
+Config::save_template (shared_ptr<const Film> film, string name) const
+{
+ film->write_template (template_path (name));
+}
+
+list<string>
+Config::templates () const
+{
+ if (!boost::filesystem::exists (path ("templates"))) {
+ return list<string> ();
+ }
+
+ 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));
+}
+
+/** @return Path to the config.xml containing the actual settings, following a link if required */
+boost::filesystem::path
+Config::config_file ()
+{
+ cxml::Document f ("Config");
+ boost::filesystem::path main = path("config.xml", false);
+ f.read_file (main);
+ optional<string> link = f.optional_string_child("Link");
+ if (link) {
+ return *link;
+ }
+
+ return main;
+}
+
+void
+Config::reset_cover_sheet ()
+{
+ set_cover_sheet_to_default ();
+ changed ();
+}
+
+void
+Config::link (boost::filesystem::path new_file) const
+{
+ xmlpp::Document doc;
+ doc.create_root_node("Config")->add_child("Link")->add_child_text(new_file.string());
+ try {
+ doc.write_to_file_formatted(path("config.xml", true).string());
+ } catch (xmlpp::exception& e) {
+ string s = e.what ();
+ trim (s);
+ throw FileError (s, path("config.xml"));
+ }
+}
+
+void
+Config::copy_and_link (boost::filesystem::path new_file) const