[Xfce4-commits] <midori:master> Use XDG_RUNTIME_DIR for temporary files

Christian Dywan noreply at xfce.org
Wed Mar 20 22:10:02 CET 2013


Updating branch refs/heads/master
         to 3c92c9ba4c5dc51a0a5a5bbf3d8cb9984715ad65 (commit)
       from 52737168ab378ee7817cd370ae650e718fcf249c (commit)

commit 3c92c9ba4c5dc51a0a5a5bbf3d8cb9984715ad65
Author: Christian Dywan <christian at twotoasts.de>
Date:   Wed Mar 20 20:36:46 2013 +0100

    Use XDG_RUNTIME_DIR for temporary files

 katze/midori-paths.vala |   20 ++++++++++++++++----
 wscript                 |    2 +-
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/katze/midori-paths.vala b/katze/midori-paths.vala
index 0652ae3..2f7f540 100644
--- a/katze/midori-paths.vala
+++ b/katze/midori-paths.vala
@@ -74,6 +74,20 @@ namespace Midori {
             return mode;
         }
 
+        private static string get_runtime_dir () {
+            #if HAVE_WIN32
+            string? runtime_dir = Environment.get_variable ("XDG_RUNTIME_DIR");
+            if (runtime_dir == null || runtime_dir == "")
+                runtime_dir = Environment.get_user_data_dir ();
+            #else
+            string? runtime_dir = Environment.get_variable ("XDG_RUNTIME_DIR");
+            if (runtime_dir == null || runtime_dir == "")
+                return Path.build_path (Path.DIR_SEPARATOR_S,
+                    Environment.get_tmp_dir (), PACKAGE_NAME + "-" + Environment.get_user_name ());
+            #endif
+            return Path.build_path (Path.DIR_SEPARATOR_S, runtime_dir, PACKAGE_NAME);
+        }
+
         public static void init (RuntimeMode new_mode, string? config) {
             assert (mode == RuntimeMode.UNDEFINED);
             assert (new_mode != RuntimeMode.UNDEFINED);
@@ -98,8 +112,7 @@ namespace Midori {
                 cache_dir_for_reading = Path.build_path (Path.DIR_SEPARATOR_S,
                     Environment.get_user_cache_dir (), PACKAGE_NAME);
                 user_data_dir_for_reading = Environment.get_user_data_dir ();
-                tmp_dir = Path.build_path (Path.DIR_SEPARATOR_S,
-                    Environment.get_tmp_dir (), "midori-" + Environment.get_user_name ());
+                tmp_dir = get_runtime_dir ();
             }
             else {
                 string? real_config = config != null && !Path.is_absolute (config)
@@ -109,8 +122,7 @@ namespace Midori {
                 cache_dir = Path.build_path (Path.DIR_SEPARATOR_S,
                     Environment.get_user_cache_dir (), PACKAGE_NAME);
                 user_data_dir = Environment.get_user_data_dir ();
-                tmp_dir = Path.build_path (Path.DIR_SEPARATOR_S,
-                    Environment.get_tmp_dir (), "midori-" + Environment.get_user_name ());
+                tmp_dir = get_runtime_dir ();
             }
 #if !HAVE_WEBKIT2
 #if HAVE_WEBKIT_1_3_13
diff --git a/wscript b/wscript
index fa4264e..e197d3e 100644
--- a/wscript
+++ b/wscript
@@ -576,7 +576,7 @@ def shutdown ():
             base = os.path.join (tempfile.gettempdir (), 'midori-test', '%s')
             if os.path.exists (base % ''):
                 shutil.rmtree (base % '')
-            for x in ['XDG_CONFIG_HOME', 'XDG_CACHE_HOME', 'XDG_DATA_HOME', 'TMPDIR']:
+            for x in ['XDG_CONFIG_HOME', 'XDG_CACHE_HOME', 'XDG_DATA_HOME', 'XDG_RUNTIME_DIR', 'TMPDIR']:
                 os.environ[x] = (base % x).lower ()
                 Utils.check_dir (os.environ[x])
 


More information about the Xfce4-commits mailing list