fix utter confusion about session _path in new sessions.
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 7 Feb 2014 18:38:15 +0000 (13:38 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 7 Feb 2014 18:56:44 +0000 (13:56 -0500)
Yikes!

libs/ardour/session_state.cc

index 1728c112446f5479db02a047a3cf5d32f2346c9c..6d535b8e59b75a82c7f2cd7199ce256b7726d0cf 100644 (file)
@@ -136,13 +136,21 @@ Session::pre_engine_init (string fullpath)
        /* discover canonical fullpath */
 
        char buf[PATH_MAX+1];
-       if (!realpath (fullpath.c_str(), buf) && (errno != ENOENT)) {
-               error << string_compose(_("Could not use path %1 (%2)"), buf, strerror(errno)) << endmsg;
-               destroy ();
-               throw failed_constructor();
-       }
 
-       _path = string(buf);
+       if (!realpath (fullpath.c_str(), buf)) {
+               if (errno == ENOENT) {
+                       /* fullpath does not exist yet, so realpath() returned
+                        * ENOENT. Just use it as-is
+                        */
+                       _path = fullpath;
+               } else {
+                       error << string_compose(_("Could not use path %1 (%2)"), buf, strerror(errno)) << endmsg;
+                       destroy ();
+                       throw failed_constructor();
+               }
+       } else {
+               _path = string(buf);
+       }
        
        /* we require _path to end with a dir separator */