copy older versions of the session file, fix up ardev to work again using %VERSION%
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 4 Jan 2007 19:12:55 +0000 (19:12 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 4 Jan 2007 19:12:55 +0000 (19:12 +0000)
git-svn-id: svn://localhost/ardour2/trunk@1268 d708f5d6-7413-0410-9779-e7cbd77b26cf

SConstruct
gtk2_ardour/SConscript
gtk2_ardour/ardev
gtk2_ardour/ardev.in [new file with mode: 0644]
gtk2_ardour/ardour.sh.in
libs/ardour/session_state.cc
libs/pbd/SConscript
libs/pbd/copyfile.cc [new file with mode: 0644]
libs/pbd/pbd/copyfile.h [new file with mode: 0644]
svn_revision.h

index b9079e34e74ec591071ccf3db6e224e034393c0d..1b04306efb64588ef15ff9547160db1140bf54b9 100644 (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
index f2c51e18a00d78c1e075cd6542947a30db000006..375dba278ba34c695137c5dabfc080ef26ecce58 100644 (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
index 04719908b48a51d8bc76f43d655ccec5b8b45359..73f657322874087f6bef670c496df8bc97f7a442 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
 . `dirname "$0"`/ardev_common.sh
-exec gtk2_ardour/ardour.bin --novst $*
+exec gtk2_ardour/ardour-2.0beta10 $*
diff --git a/gtk2_ardour/ardev.in b/gtk2_ardour/ardev.in
new file mode 100644 (file)
index 0000000..d9ba833
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+. `dirname "$0"`/ardev_common.sh
+exec gtk2_ardour/ardour-%VERSION% $*
index 835cbd4582e06e7f2953f85197ac45e459a3d51d..1bf1ffa94bf3b56cc4425a9936dfcdcb9daf667d 100644 (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% $*
 
 
index b58d414ffd66638051147cbde60726b9015cad23..9d5733b122876399451a40b5419a8cc57c09d76f 100644 (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
index f5c65c3b2cbb9f7d6fecfab40fec52052af140cb..afb24a43117920dd60202fc19af7df2227c9466b 100644 (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
diff --git a/libs/pbd/copyfile.cc b/libs/pbd/copyfile.cc
new file mode 100644 (file)
index 0000000..d36ecef
--- /dev/null
@@ -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;
+}
diff --git a/libs/pbd/pbd/copyfile.h b/libs/pbd/pbd/copyfile.h
new file mode 100644 (file)
index 0000000..8a1bf24
--- /dev/null
@@ -0,0 +1,6 @@
+#include <glibmm/ustring.h>
+
+namespace PBD {
+
+       int copy_file (Glib::ustring from, Glib::ustring to);
+}
index 4e065cd91919cea75f7c87a27672e1b692d741d4..cddf78e774c9fb4e8f69302726960290069c24fa 100644 (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