13
0

copy older versions of the session file, fix up ardev to work again using %VERSION%

git-svn-id: svn://localhost/ardour2/trunk@1268 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2007-01-04 19:12:55 +00:00
parent 588910d8d7
commit 119dc86f6f
10 changed files with 112 additions and 41 deletions

View File

@ -16,7 +16,7 @@ import SCons.Node.FS
SConsignFile()
EnsureSConsVersion(0, 96)
version = '2.0beta10'
ardour_version = '2.0beta10'
subst_dict = { }
@ -76,11 +76,11 @@ class LibraryInfo(Environment):
env = LibraryInfo (options = opts,
CPPPATH = [ '.' ],
VERSION = version,
TARBALL='ardour-' + version + '.tar.bz2',
VERSION = ardour_version,
TARBALL='ardour-' + ardour_version + '.tar.bz2',
DISTFILES = [ ],
DISTTREE = '#ardour-' + version,
DISTCHECKDIR = '#ardour-' + version + '/check'
DISTTREE = '#ardour-' + ardour_version,
DISTCHECKDIR = '#ardour-' + ardour_version + '/check'
)
env.ENV_update(os.environ)
@ -1034,7 +1034,7 @@ env = conf.Finish()
if env['NLS'] == 1:
env.Append(CCFLAGS="-DENABLE_NLS")
Export('env install_prefix final_prefix config_prefix final_config_prefix libraries i18n version subst_dict')
Export('env install_prefix final_prefix config_prefix final_config_prefix libraries i18n ardour_version subst_dict')
#
# the configuration file may be system dependent

View File

@ -4,7 +4,7 @@ import os
import os.path
import glob
Import('env install_prefix final_prefix config_prefix libraries i18n version')
Import('env install_prefix final_prefix config_prefix libraries i18n ardour_version')
gtkardour = env.Copy()
gtkmmtests = env.Copy()
@ -260,7 +260,7 @@ versionflag = '-DVERSIONSTRING=\\\"' + env['VERSION'] + '\\\"'
gtkardour.Append(CXXFLAGS=versionflag)
executable = 'ardour.bin'
executable = 'ardour-' + ardour_version
ardour = gtkardour.Program(target = executable, source = gtkardour_files + extra_sources)
ardourlib = gtkardour.SharedLibrary(target = 'ardourgtk', source = gtkardour_files + extra_sources)
@ -273,10 +273,17 @@ tt = gtkmmtests.Program(target = 'tt', source = tt_files)
my_subst_dict = { }
my_subst_dict['%INSTALL_PREFIX%'] = final_prefix
my_subst_dict['%LIBDIR%'] = env['LIBDIR']
my_subst_dict['%VERSION%'] = ardour_version
ardoursh = env.SubstInFile ('ardour.sh','ardour.sh.in', SUBST_DICT = my_subst_dict);
env.AddPostAction (ardoursh, Chmod ('$TARGET', 0755))
ardourdev = env.SubstInFile ('ardev','ardev.in', SUBST_DICT = my_subst_dict);
env.AddPostAction (ardourdev, Chmod ('$TARGET', 0755))
Default(ardourdev)
Default(ardoursh)
if env['VST']:
Default(ardourlib)
# the library - into the library dir

View File

@ -1,3 +1,3 @@
#!/bin/sh
. `dirname "$0"`/ardev_common.sh
exec gtk2_ardour/ardour.bin --novst $*
exec gtk2_ardour/ardour-2.0beta10 $*

3
gtk2_ardour/ardev.in Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh
. `dirname "$0"`/ardev_common.sh
exec gtk2_ardour/ardour-%VERSION% $*

View File

@ -6,6 +6,6 @@ export LD_LIBRARY_PATH=%INSTALL_PREFIX%/%LIBDIR%/ardour2:$LD_LIBRARY_PATH
# DYLD_LIBRARY_PATH is for Darwin
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
exec %INSTALL_PREFIX%/%LIBDIR%/ardour2/ardour.bin $*
exec %INSTALL_PREFIX%/%LIBDIR%/ardour2/ardour-%VERSION% $*

View File

@ -55,6 +55,7 @@
#include <pbd/pthread_utils.h>
#include <pbd/strsplit.h>
#include <pbd/stacktrace.h>
#include <pbd/copyfile.h>
#include <ardour/audioengine.h>
#include <ardour/configuration.h>
@ -604,29 +605,7 @@ Session::save_state (string snapshot_name, bool pending)
bak_path += ".bak";
if (g_file_test (xml_path.c_str(), G_FILE_TEST_EXISTS)) {
// Make backup of state file
ifstream in (xml_path.c_str());
ofstream out (bak_path.c_str());
if (!in) {
error << string_compose (_("Could not open existing session file %1 for backup"), xml_path) << endmsg;
return -1;
}
if (!out) {
error << string_compose (_("Could not open backup session file %1"), bak_path) << endmsg;
return -1;
}
out << in.rdbuf();
if (!in || !out) {
error << string_compose (_("Could not copy existing session file %1 to %2 for backup"), xml_path, bak_path) << endmsg;
unlink (bak_path.c_str());
return -1;
}
copy_file (xml_path, bak_path);
}
} else {
@ -730,15 +709,52 @@ Session::load_state (string snapshot_name)
set_dirty();
if (state_tree->read (xmlpath)) {
return 0;
} else {
if (!state_tree->read (xmlpath)) {
error << string_compose(_("Could not understand ardour file %1"), xmlpath) << endmsg;
delete state_tree;
state_tree = 0;
return -1;
}
delete state_tree;
state_tree = 0;
return -1;
XMLNode& root (*state_tree->root());
if (root.name() != X_("Session")) {
error << string_compose (_("Session file %1 is not an Ardour session"), xmlpath) << endmsg;
delete state_tree;
state_tree = 0;
return -1;
}
const XMLProperty* prop;
bool is_old = false;
if ((prop = root.property ("version")) == 0) {
/* no version implies very old version of Ardour */
is_old = true;
} else {
int major_version;
major_version = atoi (prop->value()); // grab just the first number before the period
if (major_version < 2) {
is_old = true;
}
}
if (is_old) {
string backup_path;
backup_path = xmlpath;
backup_path += ".1";
info << string_compose (_("Copying old session file %1 to %2\nUse %2 with Ardour versions before 2.0 from now on"),
xmlpath, backup_path)
<< endmsg;
copy_file (xmlpath, backup_path);
/* if it fails, don't worry. right? */
}
return 0;
}
int

View File

@ -20,8 +20,9 @@ pbd.Append(POTFILE=domain + '.pot')
pbd_files = Split("""
basename.cc
base_ui.cc
convert.cc
command.cc
convert.cc
copyfile.cc
controllable.cc
enumwriter.cc
dmalloc.cc

38
libs/pbd/copyfile.cc Normal file
View File

@ -0,0 +1,38 @@
#include <fstream>
#include <unistd.h>
#include <pbd/copyfile.h>
#include <pbd/error.h>
#include <pbd/compose.h>
#include "i18n.h"
using namespace PBD;
using namespace std;
int
PBD::copy_file (Glib::ustring from, Glib::ustring to)
{
ifstream in (from.c_str());
ofstream out (to.c_str());
if (!in) {
error << string_compose (_("Could not open %1 for copy"), from) << endmsg;
return -1;
}
if (!out) {
error << string_compose (_("Could not open %1 as copy"), to) << endmsg;
return -1;
}
out << in.rdbuf();
if (!in || !out) {
error << string_compose (_("Could not copy existing file %1 to %2"), from, to) << endmsg;
unlink (to.c_str());
return -1;
}
return 0;
}

6
libs/pbd/pbd/copyfile.h Normal file
View File

@ -0,0 +1,6 @@
#include <glibmm/ustring.h>
namespace PBD {
int copy_file (Glib::ustring from, Glib::ustring to);
}

View File

@ -1,4 +1,4 @@
#ifndef __ardour_svn_revision_h__
#define __ardour_svn_revision_h__
static const char* ardour_svn_revision = "1239";
static const char* ardour_svn_revision = "1266";
#endif