[vlc-devel] commit: modules: On Windows, Mac OS X and BeOS, search for modules, in the current directory, and next to the executable. (Pierre d'Herbemont )

git version control git at videolan.org
Fri Mar 28 18:43:56 CET 2008


vlc | branch: master | Pierre d'Herbemont <pdherbemont at videolan.org> | Fri Mar 28 18:43:47 2008 +0100| [58e0c8260c3588e1613ad3730fec5c7c8ffaec2d]

modules: On Windows, Mac OS X and BeOS, search for modules, in the current directory, and next to the executable.

I would appreciate review.

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

 src/modules/modules.c |   62 +++++++++++++++++++++++-------------------------
 1 files changed, 30 insertions(+), 32 deletions(-)

diff --git a/src/modules/modules.c b/src/modules/modules.c
index b60f9cb..13cf4e6 100644
--- a/src/modules/modules.c
+++ b/src/modules/modules.c
@@ -953,34 +953,53 @@ static char * copy_next_paths_token( char * paths, char ** remaining_paths )
 static void AllocateAllPlugins( vlc_object_t *p_this )
 {
     char *paths, *path, *paths_iter;
+    char * extra_path;
+
+    /* Contruct the special search path for system that have a relocatable
+     * executable. Set it to <vlc path>/modules and <vlc path>/plugins. */
+#if defined( WIN32 ) || defined( UNDER_CE ) || defined( __APPLE__ ) || defined( SYS_BEOS )
+    if( asprintf( &extra_path,
+                    "%s" DIR_SEP "modules" PATH_SEP
+                    "%s" DIR_SEP "plugins"
+                    "%s",
+                    vlc_global()->psz_vlcpath,
+                    vlc_global()->psz_vlcpath,
+# if defined( WIN32 ) || defined( UNDER_CE )
+                    "" ) < 0 )
+# else
+                    PATH_SEP PLUGIN_PATH ) < 0 )
+# endif
 
-#if defined( WIN32 ) || defined( UNDER_CE )
-    const char * extra_path = NULL;
+    {
+        msg_Err( p_this, "Not enough memory" );
+        return;
+    }
 #else
-    const char * extra_path = PLUGIN_PATH;
+    extra_path = strdup( PLUGIN_PATH );
 #endif
 
     /* If the user provided a plugin path, we add it to the list */
     char * userpaths = config_GetPsz( p_this, "plugin-path" );
 
-    if( asprintf( &paths, "modules%s%s"PATH_SEP"plugins%s%s",
-                    extra_path ? PATH_SEP : "",
-                    extra_path ? extra_path : "",
+    if( asprintf( &paths, "modules" PATH_SEP "%s" PATH_SEP "plugins%s%s",
+                    extra_path,
                     userpaths ? PATH_SEP : "",
                     userpaths ? userpaths : "" ) < 0 )
     {
         msg_Err( p_this, "Not enough memory" );
         free( userpaths );
+        free( extra_path );
         return;
     }
 
-    /* Free plugin-path */
+    /* Free plugin-path and extra path */
     free( userpaths );
+    free( extra_path );
+
+    msg_Dbg( p_this, "We will be looking for modules in `%s'", paths );
 
     for( paths_iter = paths; paths_iter; )
     {
-        char *psz_fullpath;
-
         path = copy_next_paths_token( paths_iter, &paths_iter );
         if( !path )
         {
@@ -988,32 +1007,11 @@ static void AllocateAllPlugins( vlc_object_t *p_this )
             return;
         }
 
-#if defined( SYS_BEOS ) || defined( __APPLE__ ) || defined( WIN32 )
-
-        /* Handle relative as well as absolute paths */
-#ifdef WIN32
-        if( path[0] != '\\' && path[0] != '/' && path[0] != ':' )
-#else
-        if( path[0] != '/' )
-#endif
-        {
-            if( 0>= asprintf( &psz_fullpath, "%s"DIR_SEP"%s",
-                              vlc_global()->psz_vlcpath, path) )
-                psz_fullpath = NULL;
-        }
-        else
-#endif
-            psz_fullpath = strdup( path );
-
-        if( psz_fullpath == NULL )
-            continue;
-
-        msg_Dbg( p_this, "recursively browsing `%s'", psz_fullpath );
+        msg_Dbg( p_this, "recursively browsing `%s'", path );
 
         /* Don't go deeper than 5 subdirectories */
-        AllocatePluginDir( p_this, psz_fullpath, 5 );
+        AllocatePluginDir( p_this, path, 5 );
 
-        free( psz_fullpath );
         free( path );
     }
 




More information about the vlc-devel mailing list