[vlc-devel] commit: config: On Mac OS use the app identifier for app dependent config dirs. (Pierre d' Herbemont )

git version control git at videolan.org
Wed Dec 30 02:30:55 CET 2009


vlc | branch: master | Pierre d'Herbemont <pdherbemont at free.fr> | Wed Dec 30 02:27:08 2009 +0100| [a57a4a64dead1bf8a477a7fa04bf021573703f1f] | committer: Pierre d'Herbemont 

config: On Mac OS use the app identifier for app dependent config dirs.

This may hopefully spare us some conflicts with VLCKit/libvlc users.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a57a4a64dead1bf8a477a7fa04bf021573703f1f
---

 src/config/dirs_macos.c |   49 ++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/src/config/dirs_macos.c b/src/config/dirs_macos.c
index a411fc6..fdb272a 100644
--- a/src/config/dirs_macos.c
+++ b/src/config/dirs_macos.c
@@ -22,6 +22,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
+#include <CoreFoundation/CoreFoundation.h>
+
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -31,6 +33,7 @@
 #include "../libvlc.h"
 #include <vlc_charset.h>
 #include <vlc_configuration.h>
+#include "configuration.h"
 
 static char *configdir = NULL;
 static char *datadir = NULL;
@@ -65,21 +68,50 @@ static char *config_GetHomeDir (void)
     return FromLocaleDup (home);
 }
 
-char *config_GetUserDir (vlc_userdir_t type)
+static char *getAppDependentDir(vlc_userdir_t type)
 {
-    char *psz_dir;
-    char *psz_parent = config_GetHomeDir ();
     const char *psz_path;
-
     switch (type)
     {
         case VLC_CONFIG_DIR:
-            psz_path = "%s/Library/Preferences/VLC";
+            psz_path = "%s/Library/Preferences/%s";
             break;
         case VLC_TEMPLATES_DIR:
         case VLC_DATA_DIR:
-            psz_path = "%s/Library/Application Support/VLC";
+            psz_path = "%s/Library/Application Support/%s";
+            break;
+        case VLC_CACHE_DIR:
+            psz_path = "%s/Library/Caches/%s";
+            break;
+        default:
+            assert(0);
             break;
+    }
+
+    CFBundleRef mainBundle = CFBundleGetMainBundle();
+    CFStringRef identifierAsNS = CFBundleGetIdentifier(mainBundle);
+    const char *identifier = CFStringGetCStringPtr(identifierAsNS, kCFStringEncodingUTF8);
+    
+    char *psz_parent = config_GetHomeDir ();
+    char *psz_dir;
+    if( asprintf( &psz_dir, psz_path, psz_parent, identifier) == -1 )
+        psz_dir = NULL;
+    free(psz_parent);
+
+    return psz_dir;    
+}
+
+char *config_GetUserDir (vlc_userdir_t type)
+{
+    const char *psz_path;
+    switch (type)
+    {
+        case VLC_CONFIG_DIR:
+        case VLC_TEMPLATES_DIR:
+        case VLC_DATA_DIR:
+        case VLC_CACHE_DIR:
+            return getAppDependentDir(type);
+
         case VLC_DESKTOP_DIR:
             psz_path = "%s/Desktop";
             break;
@@ -101,13 +133,12 @@ char *config_GetUserDir (vlc_userdir_t type)
         case VLC_PUBLICSHARE_DIR:
             psz_path = "%s/Public";
             break;
-        case VLC_CACHE_DIR:
-            psz_path = "%s/Library/Caches/org.videolan.vlc";
-            break;
         case VLC_HOME_DIR:
         default:
             psz_path = "%s";
     }
+    char *psz_parent = config_GetHomeDir ();
+    char *psz_dir;
     if( asprintf( &psz_dir, psz_path, psz_parent ) == -1 )
         psz_dir = NULL;
     free(psz_parent);




More information about the vlc-devel mailing list