mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-15 19:16:40 +01:00
Modify Session::save_template for portablity
git-svn-id: svn://localhost/ardour2/trunk@2017 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
6b1cd68104
commit
56a27e8734
1 changed files with 19 additions and 19 deletions
|
|
@ -101,6 +101,8 @@
|
|||
#include <ardour/playlist_factory.h>
|
||||
#include <ardour/filename_extensions.h>
|
||||
#include <ardour/directory_names.h>
|
||||
#include <ardour/template_utils.h>
|
||||
|
||||
#include <control_protocol/control_protocol.h>
|
||||
|
||||
#include "i18n.h"
|
||||
|
|
@ -1584,34 +1586,32 @@ Session::save_template (string template_name)
|
|||
return -1;
|
||||
}
|
||||
|
||||
DIR* dp;
|
||||
string dir = template_dir();
|
||||
sys::path user_template_dir(user_template_directory());
|
||||
|
||||
if ((dp = opendir (dir.c_str()))) {
|
||||
closedir (dp);
|
||||
} else {
|
||||
if (g_mkdir_with_parents (dir.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
|
||||
error << string_compose(_("Could not create mix templates directory \"%1\" (%2)"), dir, strerror (errno)) << endmsg;
|
||||
return -1;
|
||||
}
|
||||
try
|
||||
{
|
||||
sys::create_directories (user_template_dir);
|
||||
}
|
||||
catch(sys::filesystem_error& ex)
|
||||
{
|
||||
error << string_compose(_("Could not create mix templates directory \"%1\" (%2)"),
|
||||
user_template_dir.to_string(), ex.what()) << endmsg;
|
||||
return -1;
|
||||
}
|
||||
|
||||
tree.set_root (&get_template());
|
||||
|
||||
xml_path = dir;
|
||||
xml_path += template_name;
|
||||
xml_path += template_suffix;
|
||||
sys::path template_file_path(user_template_dir);
|
||||
template_file_path /= template_name + template_suffix;
|
||||
|
||||
ifstream in(xml_path.c_str());
|
||||
|
||||
if (in) {
|
||||
warning << string_compose(_("Template \"%1\" already exists - new version not created"), template_name) << endmsg;
|
||||
if (sys::exists (template_file_path))
|
||||
{
|
||||
warning << string_compose(_("Template \"%1\" already exists - new version not created"),
|
||||
template_file_path.to_string()) << endmsg;
|
||||
return -1;
|
||||
} else {
|
||||
in.close();
|
||||
}
|
||||
|
||||
if (!tree.write (xml_path)) {
|
||||
if (!tree.write (template_file_path.to_string())) {
|
||||
error << _("mix template not saved") << endmsg;
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue