[vlc-devel] commit: dirs_macos: When running from command line there is no bundle identifier by default. ( Pierre d'Herbemont )

git version control git at videolan.org
Wed Jan 6 16:28:57 CET 2010


vlc | branch: master | Pierre d'Herbemont <pdherbemont at free.fr> | Wed Jan  6 16:02:15 2010 +0100| [b25b7890e2c5166fa19c6ebbd43369ddc6d89547] | committer: Pierre d'Herbemont 

dirs_macos: When running from command line there is no bundle identifier by default.

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

 src/config/dirs_macos.c |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/config/dirs_macos.c b/src/config/dirs_macos.c
index fc91de2..7c00f02 100644
--- a/src/config/dirs_macos.c
+++ b/src/config/dirs_macos.c
@@ -90,13 +90,25 @@ static char *getAppDependentDir(vlc_userdir_t type)
             break;
     }
 
+    // Default fallback
+    const char *name = "org.videolan.vlc";
+
     CFBundleRef mainBundle = CFBundleGetMainBundle();
-    CFStringRef identifierAsNS = CFBundleGetIdentifier(mainBundle);
-    const char *identifier = CFStringGetCStringPtr(identifierAsNS, kCFStringEncodingUTF8);
-    
+    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, identifier) == -1 )
+    if( asprintf( &psz_dir, psz_path, psz_parent, name) == -1 )
         psz_dir = NULL;
     free(psz_parent);
 




More information about the vlc-devel mailing list