diff options
author | Johannes Mueller <github@johannes-mueller.org> | 2017-07-07 22:01:01 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2017-07-12 16:15:03 +0200 |
commit | 96a9437289af972f45b2105c0db5e150ccb3d12e (patch) | |
tree | c36e82b703deb75930c9be60748d4539ef1902ef /gtk2_ardour/template_dialog.cc | |
parent | a73a5e921578f03469ed6c19aa55694d6e38ca9d (diff) |
Switch to g_dir_make_tmp() to make the tmpdir.
Diffstat (limited to 'gtk2_ardour/template_dialog.cc')
-rw-r--r-- | gtk2_ardour/template_dialog.cc | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/gtk2_ardour/template_dialog.cc b/gtk2_ardour/template_dialog.cc index 1346f7dd8b..4b3b9ca9a4 100644 --- a/gtk2_ardour/template_dialog.cc +++ b/gtk2_ardour/template_dialog.cc @@ -217,33 +217,6 @@ TemplateManager::key_event (GdkEventKey* ev) return false; } -static string get_tmp_dir () -{ - #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) { - return string (); - } - - char tmptpl[1024]; - strcpy (tmptpl, tmp); - strcat (tmptpl, "ardour_template-XXXXXX"); - char* tmpdir = g_mkdtemp (tmptpl); - - if (!tmpdir) { - return string (); - } - - return string (tmpdir); -} - static bool accept_all_files (string const &, void *) { @@ -259,6 +232,17 @@ static void _set_progress (Progress* p, size_t n, size_t t) void TemplateManager::export_all_templates () { + GError* err = NULL; + char* td = g_dir_make_tmp ("ardour-templates-XXXXXX", &err); + + if (!td) { + error << string_compose(_("Could not make tmpdir: %1"), err->message) << endmsg; + return; + } + const string tmpdir (td); + g_free (td); + g_clear_error (&err); + FileChooserDialog dialog(_("Save Exported Template Archive"), FILE_CHOOSER_ACTION_SAVE); dialog.set_filename (X_("templates.tar.xz")); @@ -276,8 +260,6 @@ TemplateManager::export_all_templates () return; } - const string tmpdir = get_tmp_dir(); - PBD::copy_recurse (templates_dir (), tmpdir); vector<string> files; |