]> git.sesse.net Git - vlc/commitdiff
dirs_macos: When running from command line there is no bundle identifier by default.
authorPierre d'Herbemont <pdherbemont@free.fr>
Wed, 6 Jan 2010 15:02:15 +0000 (16:02 +0100)
committerPierre d'Herbemont <pdherbemont@free.fr>
Wed, 6 Jan 2010 15:28:54 +0000 (16:28 +0100)
src/config/dirs_macos.c

index fc91de2e1cf3d159696e30b959d770b7059aace2..7c00f022b5fe04d144a6f04920f670eea3d83b50 100644 (file)
@@ -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);