[hyena] Paths: Allow different names for system vs user paths



commit 257c6b691c1a4c13b6b0123d8b51d31fbd22c30e
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Mon Mar 14 13:50:02 2011 -0500

    Paths: Allow different names for system vs user paths
    
    Banshee is renaming most everything from banshee-1 to banshee, with the
    exception of the ~/.config and ~/.cache directories.
    
    Add UserApplicationName property, which defaults to ApplicationName, but
    can be set so that the app cache and config/data directories can be
    "banshee-1" while the system directories can be "banshee".

 Hyena/Hyena/Paths.cs |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/Hyena/Hyena/Paths.cs b/Hyena/Hyena/Paths.cs
index aa847ce..69b619a 100644
--- a/Hyena/Hyena/Paths.cs
+++ b/Hyena/Hyena/Paths.cs
@@ -180,14 +180,26 @@ namespace Hyena
             set { application_name = value; InitializePaths (); }
         }
 
+        private static string user_application_name = null;
+        public static string UserApplicationName {
+            get {
+                var application_name = user_application_name ?? ApplicationName;
+                if (application_name == null) {
+                    throw new ApplicationException ("Paths.ApplicationName must be set first");
+                }
+                return application_name;
+            }
+            set { user_application_name = value; }
+        }
+
         // This can only happen after ApplicationName is set.
         private static void InitializePaths ()
         {
             ApplicationCache = Path.Combine (XdgBaseDirectorySpec.GetUserDirectory (
-                "XDG_CACHE_HOME", ".cache"), ApplicationName);
+                "XDG_CACHE_HOME", ".cache"), UserApplicationName);
 
             ApplicationData = Path.Combine (Environment.GetFolderPath (
-                Environment.SpecialFolder.ApplicationData), ApplicationName);
+                Environment.SpecialFolder.ApplicationData), UserApplicationName);
             if (!Directory.Exists (ApplicationData)) {
                 Directory.CreateDirectory (ApplicationData);
             }
@@ -202,6 +214,8 @@ namespace Hyena
             get { return "/tmp/"; }
         }
 
+        // FIXME the behavior of calling this getter is very unexpected;
+        // it's not thread-safe and really shouldn't delete anything
         public static string TempDir {
             get {
                 string dir = Path.Combine (ApplicationCache, "temp");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]