From d52631cb674bbd193843ea3c2fd026d0cb240e2e Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 14 Dec 2008 01:19:50 +0000 Subject: [PATCH] (trunk libT) #1595: Always search in PACKAGE_DATA_DIR when serving Web files --- libtransmission/platform.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/libtransmission/platform.c b/libtransmission/platform.c index f1e5a5987..786a4d9d3 100644 --- a/libtransmission/platform.c +++ b/libtransmission/platform.c @@ -10,6 +10,8 @@ * $Id$ */ +#include + #ifdef WIN32 #include #include /* 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 */