+ case VLC_CACHE_DIR:
+ psz_path = "%s/Library/Caches/%s";
+ break;
+ default:
+ assert(0);
+ break;
+ }
+
+ // Default fallback
+ const char *name = "org.videolan.vlc";
+
+ CFBundleRef mainBundle = CFBundleGetMainBundle();
+ if (mainBundle)
+ {
+ CFStringRef identifierAsNS = CFBundleGetIdentifier(mainBundle);
+ if (identifierAsNS)
+ {
+ char identifier[256];
+ Boolean ret = CFStringGetCString(identifierAsNS, identifier, sizeof(identifier), kCFStringEncodingUTF8);
+ if (ret)
+ name = identifier;
+ }
+ }
+
+ char *psz_parent = config_GetHomeDir ();
+ char *psz_dir;
+ if( asprintf( &psz_dir, psz_path, psz_parent, name) == -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);
+