Allow configuration of KDM filename format.
[dcpomatic.git] / src / lib / screen_kdm.cc
index 60a81399d3c79c0714e393230bbf0137ec07d845..52590bc55a1fb1c9499b473214a4b7371fdf41b2 100644 (file)
@@ -1,19 +1,20 @@
 /*
     Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
 
-    This program is free software; you can redistribute it and/or modify
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
 
-    This program is distributed in the hope that it will be useful,
+    DCP-o-matic is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 
@@ -33,19 +34,14 @@ operator== (ScreenKDM const & a, ScreenKDM const & b)
        return a.screen == b.screen && a.kdm == b.kdm;
 }
 
-/** @param first_part first part of the filename (perhaps the name of the film) */
-string
-ScreenKDM::filename (string first_part) const
-{
-       return tidy_for_filename (first_part) + "_" + tidy_for_filename (screen->cinema->name) + "_" + tidy_for_filename (screen->name) + ".kdm.xml";
-}
-
 void
-ScreenKDM::write_files (string name_first_part, list<ScreenKDM> screen_kdms, boost::filesystem::path directory)
+ScreenKDM::write_files (list<ScreenKDM> screen_kdms, boost::filesystem::path directory, KDMNameFormat name_format, NameFormat::Map name_values)
 {
        /* Write KDMs to the specified directory */
        BOOST_FOREACH (ScreenKDM const & i, screen_kdms) {
-               boost::filesystem::path out = directory / i.filename(name_first_part);
+               name_values["cinema"] = i.screen->cinema->name;
+               name_values["screen"] = i.screen->name;
+               boost::filesystem::path out = directory / (name_format.get(name_values) + ".xml");
                i.kdm.as_xml (out);
        }
 }