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$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <event.h>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <shlobj.h> /* for CSIDL_APPDATA, CSIDL_MYDOCUMENTS */
|
#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 */
|
/* XDG_DATA_DIRS are the backup directories */
|
||||||
tmp = getenv( "XDG_DATA_DIRS" );
|
{
|
||||||
if( !tmp || !*tmp )
|
struct evbuffer * buf = evbuffer_new( );
|
||||||
tmp = PACKAGE_DATA_DIR ":/usr/local/share/:/usr/share/";
|
evbuffer_add_printf( buf, "%s:", PACKAGE_DATA_DIR );
|
||||||
while( tmp && *tmp ) {
|
if(( tmp = getenv( "XDG_DATA_DIRS" )))
|
||||||
const char * end = strchr( tmp, ':' );
|
evbuffer_add_printf( buf, "%s:", tmp );
|
||||||
if( end ) {
|
evbuffer_add_printf( buf, "%s:", "/usr/local/share" );
|
||||||
tr_list_append( &candidates, tr_strndup( tmp, end - tmp ) );
|
evbuffer_add_printf( buf, "%s:", "/usr/share" );
|
||||||
tmp = end + 1;
|
tmp = (const char*) EVBUFFER_DATA( buf );
|
||||||
} else {
|
while( tmp && *tmp ) {
|
||||||
tr_list_append( &candidates, tr_strdup( tmp ) );
|
const char * end = strchr( tmp, ':' );
|
||||||
break;
|
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 */
|
/* walk through the candidates & look for a match */
|
||||||
|
|
Loading…
Reference in a new issue