Changeset 4179


Ignore:
Timestamp:
Dec 15, 2007, 10:22:30 PM (13 years ago)
Author:
charles
Message:

add support for TRANSMISSION_HOME environment variable so I can have multiple copies of Transmission running concurrently in different directories.

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fdlimit.c

    r4177 r4179  
    8989    TR_MAX_SOCKETS = 512,
    9090
    91     TR_MAX_OPEN_FILES = 8, /* real files, not sockets */
     91    TR_MAX_OPEN_FILES = 16, /* real files, not sockets */
    9292
    9393    TR_RESERVED_FDS = 16 /* sockets reserved for tracker connections */
  • trunk/libtransmission/platform.c

    r4108 r4179  
    5555#include "net.h"
    5656#include "platform.h"
     57#include "trcompat.h"
    5758#include "utils.h"
    5859
     
    288289#endif
    289290
    290 const char *
     291static const char *
    291292tr_getHomeDirectory( void )
    292293{
     
    349350    static char   buf[MAX_PATH_LENGTH];
    350351    static int    init = 0;
    351     static size_t buflen = sizeof(buf);
    352     const char* h;
     352    const char * trhome;
    353353
    354354    if( init )
    355355        return buf;
    356356
    357     h = tr_getHomeDirectory();
    358 #ifdef __BEOS__
    359     find_directory( B_USER_SETTINGS_DIRECTORY,
    360                     dev_for_path("/boot"), true, buf, buflen );
    361     strcat( buf, "/Transmission" );
     357    trhome = getenv( "TRANSMISSION_HOME" );
     358    if( trhome != NULL )
     359    {
     360        strlcpy( buf, trhome, sizeof( buf ) );
     361    }
     362    else
     363    {
     364#ifdef __BEOS__
     365        find_directory( B_USER_SETTINGS_DIRECTORY,
     366                        dev_for_path("/boot"), true,
     367                        buf, sizeof( buf ) );
     368        strcat( buf, "/Transmission" );
    362369#elif defined( SYS_DARWIN )
    363     tr_buildPath ( buf, buflen, h,
    364                   "Library", "Application Support", "Transmission", NULL );
     370        const char * h = tr_getHomeDirectory( );
     371        tr_buildPath ( buf, sizeof( buf ),
     372                       tr_getHomeDirectory( ),
     373                       "Library",
     374                       "Application Support",
     375                       "Transmission",
     376                       NULL );
    365377#elif defined(__AMIGAOS4__)
    366     snprintf( buf, buflen, "PROGDIR:.transmission" );
    367 #elif defined(WIN32)
    368     {
    369         char tmp[MAX_PATH_LENGTH];
    370         SHGetFolderPath( NULL, CSIDL_APPDATA, NULL, 0, tmp );
    371         tr_buildPath( buf, sizeof(buf), tmp, "Transmission", NULL );
    372         buflen = strlen( buf );
     378        strlcpy( buf, "PROGDIR:.transmission", sizeof( buf ) );
     379#elif defined(WIN32)
     380        char appdata[MAX_PATH_LENGTH];
     381        SHGetFolderPath( NULL, CSIDL_APPDATA, NULL, 0, appdata );
     382        tr_buildPath( buf, sizeof(buf),
     383                      appdata,
     384                      "Transmission",
     385                      NULL );
     386#else
     387        tr_buildPath ( buf, sizeof(buf), tr_getHomeDirectory( ), ".transmission", NULL );
     388#endif
    373389    }
    374 #else
    375     tr_buildPath ( buf, buflen, h, ".transmission", NULL );
    376 #endif
    377390
    378391    tr_mkdirp( buf, 0777 );
  • trunk/libtransmission/platform.h

    r4092 r4179  
    2828typedef struct tr_thread tr_thread;
    2929
    30 const char * tr_getHomeDirectory( void );
    3130const char * tr_getCacheDirectory( void );
    3231const char * tr_getTorrentsDirectory( void );
Note: See TracChangeset for help on using the changeset viewer.