From d1229a263c203b6879c2cf85fd04b3b0ad1aace2 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Wed, 24 Mar 2010 23:41:08 +0000 Subject: [PATCH] #3072 Make Transmission look for the web ui folder in the Application Support folder first --- libtransmission/platform.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/libtransmission/platform.c b/libtransmission/platform.c index c16b04349..3e4afba3c 100644 --- a/libtransmission/platform.c +++ b/libtransmission/platform.c @@ -544,27 +544,38 @@ tr_getWebClientDir( const tr_session * session UNUSED ) else { -#ifdef SYS_DARWIN /* on Mac, look in the app package first, then the Application Support folder (for daemon, etc) */ +#ifdef SYS_DARWIN /* on Mac, look in the Application Support folder first, then in the app bundle. */ - CFURLRef appURL = CFBundleCopyBundleURL( CFBundleGetMainBundle( ) ); - CFStringRef appRef = CFURLCopyFileSystemPath( appURL, - kCFURLPOSIXPathStyle ); - const char * appString = CFStringGetCStringPtr( appRef, - CFStringGetFastestEncoding( appRef ) ); - CFRelease( appURL ); - CFRelease( appRef ); - - s = tr_buildPath( appString, "Contents", "Resources", "web", NULL ); + /* Look in the Application Support folder */ + s = tr_buildPath( tr_sessionGetConfigDir( session ), "web", NULL ); if( !isWebClientDir( s ) ) { tr_free( s ); - /* Fallback to the Application Support folder */ - s = tr_buildPath( tr_sessionGetConfigDir( session ), "web", NULL ); + CFURLRef appURL = CFBundleCopyBundleURL( CFBundleGetMainBundle( ) ); + CFStringRef appRef = CFURLCopyFileSystemPath( appURL, + kCFURLPOSIXPathStyle ); + CFIndex appLength = CFStringGetMaximumSizeForEncoding( CFStringGetLength(appRef), + CFStringGetFastestEncoding( appRef )); + + char * appString = tr_malloc( appLength + 1 ); + tr_bool success = CFStringGetCString( appRef, + appString, + appLength + 1, + CFStringGetFastestEncoding( appRef )); + assert( success ); + + CFRelease( appURL ); + CFRelease( appRef ); + + /* Fallback to the app bundle */ + s = tr_buildPath( appString, "Contents", "Resources", "web", NULL ); if( !isWebClientDir( s ) ) { tr_free( s ); s = NULL; } + + tr_free( appString ); } #elif defined( WIN32 )