Changeset 58e0c8260c3588e1613ad3730fec5c7c8ffaec2d
- Timestamp:
- 03/28/08 18:44:06
(5 months ago)
- Author:
- Pierre d'Herbemont <pdherbemont@videolan.org>
- git-committer:
- Pierre d'Herbemont <pdherbemont@videolan.org> 1206726246 +0100
- git-parent:
[69d572ca8a6bc6f9de85ed471fbb30e430fb0fe2]
- git-author:
- Pierre d'Herbemont <pdherbemont@videolan.org> 1206726227 +0100
- Message:
modules: On Windows, Mac OS X and BeOS, search for modules, in the current directory, and next to the executable.
I would appreciate review.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r38386df |
r58e0c82 |
|
| 954 | 954 | { |
|---|
| 955 | 955 | char *paths, *path, *paths_iter; |
|---|
| 956 | | |
|---|
| 957 | | #if defined( WIN32 ) || defined( UNDER_CE ) |
|---|
| 958 | | const char * extra_path = NULL; |
|---|
| | 956 | char * extra_path; |
|---|
| | 957 | |
|---|
| | 958 | /* Contruct the special search path for system that have a relocatable |
|---|
| | 959 | * executable. Set it to <vlc path>/modules and <vlc path>/plugins. */ |
|---|
| | 960 | #if defined( WIN32 ) || defined( UNDER_CE ) || defined( __APPLE__ ) || defined( SYS_BEOS ) |
|---|
| | 961 | if( asprintf( &extra_path, |
|---|
| | 962 | "%s" DIR_SEP "modules" PATH_SEP |
|---|
| | 963 | "%s" DIR_SEP "plugins" |
|---|
| | 964 | "%s", |
|---|
| | 965 | vlc_global()->psz_vlcpath, |
|---|
| | 966 | vlc_global()->psz_vlcpath, |
|---|
| | 967 | # if defined( WIN32 ) || defined( UNDER_CE ) |
|---|
| | 968 | "" ) < 0 ) |
|---|
| | 969 | # else |
|---|
| | 970 | PATH_SEP PLUGIN_PATH ) < 0 ) |
|---|
| | 971 | # endif |
|---|
| | 972 | |
|---|
| | 973 | { |
|---|
| | 974 | msg_Err( p_this, "Not enough memory" ); |
|---|
| | 975 | return; |
|---|
| | 976 | } |
|---|
| 959 | 977 | #else |
|---|
| 960 | | const char * extra_path = PLUGIN_PATH; |
|---|
| | 978 | extra_path = strdup( PLUGIN_PATH ); |
|---|
| 961 | 979 | #endif |
|---|
| 962 | 980 | |
|---|
| … | … | |
| 964 | 982 | char * userpaths = config_GetPsz( p_this, "plugin-path" ); |
|---|
| 965 | 983 | |
|---|
| 966 | | if( asprintf( &paths, "modules%s%s"PATH_SEP"plugins%s%s", |
|---|
| 967 | | extra_path ? PATH_SEP : "", |
|---|
| 968 | | extra_path ? extra_path : "", |
|---|
| | 984 | if( asprintf( &paths, "modules" PATH_SEP "%s" PATH_SEP "plugins%s%s", |
|---|
| | 985 | extra_path, |
|---|
| 969 | 986 | userpaths ? PATH_SEP : "", |
|---|
| 970 | 987 | userpaths ? userpaths : "" ) < 0 ) |
|---|
| … | … | |
| 972 | 989 | msg_Err( p_this, "Not enough memory" ); |
|---|
| 973 | 990 | free( userpaths ); |
|---|
| | 991 | free( extra_path ); |
|---|
| 974 | 992 | return; |
|---|
| 975 | 993 | } |
|---|
| 976 | 994 | |
|---|
| 977 | | /* Free plugin-path */ |
|---|
| | 995 | /* Free plugin-path and extra path */ |
|---|
| 978 | 996 | free( userpaths ); |
|---|
| | 997 | free( extra_path ); |
|---|
| | 998 | |
|---|
| | 999 | msg_Dbg( p_this, "We will be looking for modules in `%s'", paths ); |
|---|
| 979 | 1000 | |
|---|
| 980 | 1001 | for( paths_iter = paths; paths_iter; ) |
|---|
| 981 | 1002 | { |
|---|
| 982 | | char *psz_fullpath; |
|---|
| 983 | | |
|---|
| 984 | 1003 | path = copy_next_paths_token( paths_iter, &paths_iter ); |
|---|
| 985 | 1004 | if( !path ) |
|---|
| … | … | |
| 989 | 1008 | } |
|---|
| 990 | 1009 | |
|---|
| 991 | | #if defined( SYS_BEOS ) || defined( __APPLE__ ) || defined( WIN32 ) |
|---|
| 992 | | |
|---|
| 993 | | /* Handle relative as well as absolute paths */ |
|---|
| 994 | | #ifdef WIN32 |
|---|
| 995 | | if( path[0] != '\\' && path[0] != '/' && path[0] != ':' ) |
|---|
| 996 | | #else |
|---|
| 997 | | if( path[0] != '/' ) |
|---|
| 998 | | #endif |
|---|
| 999 | | { |
|---|
| 1000 | | if( 0>= asprintf( &psz_fullpath, "%s"DIR_SEP"%s", |
|---|
| 1001 | | vlc_global()->psz_vlcpath, path) ) |
|---|
| 1002 | | psz_fullpath = NULL; |
|---|
| 1003 | | } |
|---|
| 1004 | | else |
|---|
| 1005 | | #endif |
|---|
| 1006 | | psz_fullpath = strdup( path ); |
|---|
| 1007 | | |
|---|
| 1008 | | if( psz_fullpath == NULL ) |
|---|
| 1009 | | continue; |
|---|
| 1010 | | |
|---|
| 1011 | | msg_Dbg( p_this, "recursively browsing `%s'", psz_fullpath ); |
|---|
| | 1010 | msg_Dbg( p_this, "recursively browsing `%s'", path ); |
|---|
| 1012 | 1011 | |
|---|
| 1013 | 1012 | /* Don't go deeper than 5 subdirectories */ |
|---|
| 1014 | | AllocatePluginDir( p_this, psz_fullpath, 5 ); |
|---|
| 1015 | | |
|---|
| 1016 | | free( psz_fullpath ); |
|---|
| | 1013 | AllocatePluginDir( p_this, path, 5 ); |
|---|
| | 1014 | |
|---|
| 1017 | 1015 | free( path ); |
|---|
| 1018 | 1016 | } |
|---|