mirror of
https://github.com/transmission/transmission
synced 2025-02-03 21:12:05 +00:00
(trunk libT) #1595: Always search in PACKAGE_DATA_DIR when serving Web files
This commit is contained in:
parent
02521f4bf8
commit
d52631cb67
1 changed files with 20 additions and 11 deletions
|
@ -10,6 +10,8 @@
|
|||
* $Id$
|
||||
*/
|
||||
|
||||
#include <event.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#include <shlobj.h> /* for CSIDL_APPDATA, CSIDL_MYDOCUMENTS */
|
||||
|
@ -552,18 +554,25 @@ tr_getClutchDir( const tr_session * session UNUSED )
|
|||
}
|
||||
|
||||
/* XDG_DATA_DIRS are the backup directories */
|
||||
tmp = getenv( "XDG_DATA_DIRS" );
|
||||
if( !tmp || !*tmp )
|
||||
tmp = PACKAGE_DATA_DIR ":/usr/local/share/:/usr/share/";
|
||||
while( tmp && *tmp ) {
|
||||
const char * end = strchr( tmp, ':' );
|
||||
if( end ) {
|
||||
tr_list_append( &candidates, tr_strndup( tmp, end - tmp ) );
|
||||
tmp = end + 1;
|
||||
} else {
|
||||
tr_list_append( &candidates, tr_strdup( tmp ) );
|
||||
break;
|
||||
{
|
||||
struct evbuffer * buf = evbuffer_new( );
|
||||
evbuffer_add_printf( buf, "%s:", PACKAGE_DATA_DIR );
|
||||
if(( tmp = getenv( "XDG_DATA_DIRS" )))
|
||||
evbuffer_add_printf( buf, "%s:", tmp );
|
||||
evbuffer_add_printf( buf, "%s:", "/usr/local/share" );
|
||||
evbuffer_add_printf( buf, "%s:", "/usr/share" );
|
||||
tmp = (const char*) EVBUFFER_DATA( buf );
|
||||
while( tmp && *tmp ) {
|
||||
const char * end = strchr( tmp, ':' );
|
||||
if( end ) {
|
||||
tr_list_append( &candidates, tr_strndup( tmp, end - tmp ) );
|
||||
tmp = end + 1;
|
||||
} else if( tmp && *tmp ) {
|
||||
tr_list_append( &candidates, tr_strdup( tmp ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
evbuffer_free( buf );
|
||||
}
|
||||
|
||||
/* walk through the candidates & look for a match */
|
||||
|
|
Loading…
Reference in a new issue