# HG changeset patch # User Torsten Lilge # Date 1648988925 -7200 # Node ID b77b321f1ac5d34366894407369a3c700bb38b6c # Parent 1921d9d0e62bcfb99211b5823eb0092b59f5fbca use common function for getting temp dir in GUI (bug #62215) * resource-manager.cc (octave_getenv): removed; (get_temp_dir): removed; (create_tmp_file): use sys::env::get_temp_directory () * resource-manager.h: removed octave_getenv and get_temp_dir diff -r 1921d9d0e62b -r b77b321f1ac5 libgui/src/resource-manager.cc --- a/libgui/src/resource-manager.cc Sun Apr 03 12:38:19 2022 +0200 +++ b/libgui/src/resource-manager.cc Sun Apr 03 14:28:45 2022 +0200 @@ -728,57 +728,6 @@ } - // Extending getenv such taht is gets and returns std::string - std::string resource_manager::octave_getenv (const std::string& name) - { - char *value = ::getenv (name.c_str ()); - return value ? value : ""; - } - - // The following routine for determining the current temp directory - // is taken from mkoctfile.in.cc and updated such that the fallback - // is the location that QStandardPaths::writableLocation returns. - QString resource_manager::get_temp_dir () - { - std::string tempd; - - tempd = octave_getenv ("TMPDIR"); - -#if defined (__MINGW32__) || defined (_MSC_VER) - - if (tempd.empty ()) - tempd = octave_getenv ("TEMP"); - - if (tempd.empty ()) - tempd = octave_getenv ("TMP"); - -#if defined (P_tmpdir) - if (tempd.empty ()) - tempd = P_tmpdir; -#endif - - // Some versions of MinGW and MSVC either don't define P_tmpdir, or - // define it to a single backslash. - if (tempd == R"(\)") - tempd = ""; - -#else - -#if defined (P_tmpdir) - if (tempd.empty ()) - tempd = P_tmpdir; -#endif - -#endif - - if (tempd.empty ()) - return QStandardPaths::writableLocation (QStandardPaths::TempLocation) + - QDir::separator() + "octave"; - else - return QString::fromStdString (tempd); - } - - QPointer resource_manager::create_tmp_file (const QString& extension, const QString& contents) @@ -788,7 +737,7 @@ ext = QString (".") + ext; // Create octave dir within temp. dir - QString tmp_dir = get_temp_dir (); + QString tmp_dir = QString::fromStdString (sys::env::get_temp_directory ()); // Create temp. file QPointer tmp_file diff -r 1921d9d0e62b -r b77b321f1ac5 libgui/src/resource-manager.h --- a/libgui/src/resource-manager.h Sun Apr 03 12:38:19 2022 +0200 +++ b/libgui/src/resource-manager.h Sun Apr 03 14:28:45 2022 +0200 @@ -115,10 +115,6 @@ */ QFont copy_font_attributes (const QFont& attr, const QFont& base) const; - std::string octave_getenv (const std::string& name); - - QString get_temp_dir (void); - QString m_settings_directory; QString m_settings_file;