Use SessionDirectory class in place of Session::create_session_directory when creatin...
authorTim Mayberry <mojofunk@gmail.com>
Fri, 18 May 2007 02:46:19 +0000 (02:46 +0000)
committerTim Mayberry <mojofunk@gmail.com>
Fri, 18 May 2007 02:46:19 +0000 (02:46 +0000)
git-svn-id: svn://localhost/ardour2/trunk@1875 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/session.cc

index 3c43a701651b85973697c83aeed55cf421a952ae..2570b8433db9a837e14df015b6e555c6d0e664f7 100644 (file)
@@ -124,32 +124,35 @@ Session::Session (AudioEngine &eng,
                throw failed_constructor();
        }
 
-       cerr << "Loading session " << fullpath << " using snapshot " << snapshot_name << " (1)" << endl;
-
        n_physical_outputs = _engine.n_physical_outputs();
        n_physical_inputs =  _engine.n_physical_inputs();
 
        first_stage_init (fullpath, snapshot_name);
 
        initialize_start_and_end_locations(0, compute_initial_length ());
-       
-       bool new_session = !g_file_test (_path.c_str(), GFileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR));
 
-       if (new_session) {
-               // A mix_template must be specified if using this constructor
-               // to create a new session.
-               assert(mix_template);
+       SessionDirectory sdir(fullpath);
+
+       if (mix_template &&
+               sdir.create() &&
+               create_session_file_from_template (*mix_template)) {
 
-               if (!create_session_directory () ||
-                               !create_session_file_from_template (*mix_template)) {
-                       destroy ();
-                       throw failed_constructor ();
-               }
-               // Continue construction like a normal saved session from now on.
-               new_session = false;
+               cerr << "Creating session " << fullpath
+                       <<" using template" << *mix_template
+                       << endl;
+
+       } else if (sdir.is_valid ()) {
+
+               cerr << "Loading session " << fullpath
+                       << " using snapshot " << snapshot_name << " (1)"
+                       << endl;
+
+       } else {
+               destroy ();
+               throw failed_constructor ();
        }
 
-       if (second_stage_init (new_session)) {
+       if (second_stage_init (false)) {
                destroy ();
                throw failed_constructor ();
        }