diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2008-01-11 23:03:50 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2008-01-11 23:03:50 +0000 |
commit | 11faee330755fea81e051d064ca2d345db9eaf42 (patch) | |
tree | e387705efd41014685c932a1b09596632fae81a4 | |
parent | 111c99882d51f7f257e322b92878c4ce18f7a413 (diff) |
fix absolute path madness in NSD
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2901 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | gtk2_ardour/new_session_dialog.cc | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/gtk2_ardour/new_session_dialog.cc b/gtk2_ardour/new_session_dialog.cc index c6f4c1c9ff..f0df59caca 100644 --- a/gtk2_ardour/new_session_dialog.cc +++ b/gtk2_ardour/new_session_dialog.cc @@ -539,25 +539,47 @@ NewSessionDialog::set_session_name (const Glib::ustring& name) void NewSessionDialog::set_session_folder(const Glib::ustring& dir) { - char buf[PATH_MAX]; + Glib::ustring realdir = dir; + char* res; + + /* this little tangled mess is a result of 4 things: + + 1) GtkFileChooser vomits when given a non-absolute directory + argument to set_current_folder() + 2) canonicalize_file_name() doesn't exist on OS X + 3) linux man page for realpath() says "do not use this function" + 4) canonicalize_file_name() & realpath() have entirely + different semantics on OS X and Linux when given + a non-existent path. + + as result of all this, we take two distinct pathways through the code. + */ - char *res = realpath (dir.c_str(), buf); - if (res) { +#ifdef __APPLE__ - cerr << "canonical = " << res << endl; + char buf[PATH_MAX]; - Glib::ustring realdir = res; - - if (!Glib::file_test (realdir, Glib::FILE_TEST_IS_DIR)) { + if((res = realpath (dir.c_str(), buf)) != 0) { + if (!Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) { realdir = Glib::path_get_dirname (realdir); - cerr << "no such dir, use " << realdir << endl; } - m_folder->set_current_folder (realdir); - } else { - cerr << dir << " not resolvable\n"; } + + +#else + if (!Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) { + realdir = Glib::path_get_dirname (realdir); + } + + if ((res = canonicalize_file_name (realdir.c_str())) != 0) { + m_folder->set_current_folder (res); + free (res); + } + +#endif + } std::string |