From 48556cbd3c2c8e1eb5009baf7186d5cf873795f8 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 17 Mar 2021 18:05:48 +0100 Subject: [PATCH] Fix session-archive on macOS By default Apple uses a private TMP folder. While mktemp returns "/tmp/xxx" the canonical path is "/private/tmp/xxx". This lead to issues when tmp-prefix is removed when building the session-archive. See also e52bdc55ad9334a40 --- libs/ardour/session_state.cc | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index e0058f04c1..4e6712c795 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -5336,29 +5336,16 @@ Session::archive_session (const std::string& dest, } /* create temporary dir to save session to */ -#ifdef PLATFORM_WINDOWS - char tmp[256] = "C:\\TEMP\\"; - GetTempPath (sizeof (tmp), tmp); -#else - char const* tmp = getenv("TMPDIR"); - if (!tmp) { - tmp = "/tmp/"; - } -#endif - if ((strlen (tmp) + 21) > 1024) { + GError* err = NULL; + char* td = g_dir_make_tmp ("ardourarchive-XXXXXX", &err); + + if (!td) { + error << string_compose(_("Could not make tmpdir: %1"), err->message) << endmsg; return -1; } - - char tmptpl[1024]; - strcpy (tmptpl, tmp); - strcat (tmptpl, "ardourarchive-XXXXXX"); - char* tmpdir = g_mkdtemp (tmptpl); - - if (!tmpdir) { - return -1; - } - - std::string to_dir = std::string (tmpdir); + const string to_dir = PBD::canonical_path (td); + g_free (td); + g_clear_error (&err); /* switch session directory temporarily */ (*_session_dir) = to_dir;