Ticket #1406: download-dir.diff
File download-dir.diff, 7.8 KB (added by charles, 12 years ago) |
---|
-
libtransmission/utils.c
tr_loadFile( const char * path, 491 491 } 492 492 493 493 char* 494 tr_getcwd( void )495 {496 char buf[2048];497 *buf = '\0';498 #ifdef WIN32499 _getcwd( buf, sizeof( buf ) );500 #else501 getcwd( buf, sizeof( buf ) );502 #endif503 return tr_strdup( buf );504 }505 506 char*507 494 tr_basename( const char * path ) 508 495 { 509 496 char * tmp = tr_strdup( path ); -
libtransmission/utils.h
void tr_deepLog( const char * 144 144 char* tr_getLogTimeStr( char * buf, 145 145 int buflen ); 146 146 147 /** a portability wrapper for getcwd(). */148 char* tr_getcwd( void ) TR_GNUC_MALLOC;149 150 147 /** a portability wrapper for basename(). */ 151 148 char* tr_basename( const char * path ) TR_GNUC_MALLOC; 152 149 -
libtransmission/platform.c
tr_getDefaultConfigDir( void ) 483 483 return s; 484 484 } 485 485 486 const char* 487 tr_getDefaultDownloadDir( void ) 488 { 489 static char * s = NULL; 490 491 if( s == NULL ) 492 s = tr_buildPath( getHomeDir( ), "Downloads", NULL ); 493 494 return s; 495 } 496 486 497 /*** 487 498 **** 488 499 ***/ -
libtransmission/transmission.h
typedef uint64_t tr_block_index_t; 62 62 * - otherwise, if we're running on Darwin, 63 63 * "$HOME/Library/Application Support/Transmission" is returned. 64 64 * - otherwise, if we're running on WIN32, 65 * "$EXE_FOLDER/Transmission" is returned.65 * SHGetFolderPath(CSIDL_APPDATA) + "/Transmission" is returned. 66 66 * - otherwise, if XDG_CONFIG_HOME is set, 67 67 * "$XDG_CONFIG_HOME/transmission" is returned. 68 68 * - lastly, $HOME/.config/transmission" is used. 69 69 */ 70 70 const char* tr_getDefaultConfigDir( void ); 71 71 72 const char* tr_getDefaultDownloadDir( void ); 73 72 74 typedef struct tr_ctor tr_ctor; 73 75 typedef struct tr_handle tr_handle; 74 76 typedef struct tr_info tr_info; … … tr_proxy_type; 98 100 /** @see tr_sessionInitFull */ 99 101 #define TR_DEFAULT_CONFIG_DIR tr_getDefaultConfigDir( ) 100 102 /** @see tr_sessionInitFull */ 103 #define TR_DEFAULT_DOWNLOAD_DIR tr_getDefaultDownloadDir( ) 104 /** @see tr_sessionInitFull */ 101 105 #ifdef TR_EMBEDDED 102 106 #define TR_DEFAULT_ENCRYPTION TR_CLEAR_PREFERRED 103 107 #else … … tr_handle * tr_sessionInitFull( const ch 285 289 /** @brief Shorter form of tr_sessionInitFull() 286 290 @deprecated Use tr_sessionInitFull() instead. */ 287 291 tr_handle * tr_sessionInit( const char * configDir, 288 const char * downloadDir,289 292 const char * tag ); 290 293 291 294 /** @brief End a libtransmission session … … const char * tr_sessionGetConfigDir( con 306 309 * @see tr_sessionGetDownloadDir() 307 310 * @see tr_ctorSetDownloadDir() 308 311 */ 309 void tr_sessionSetDownloadDir( 310 tr_handle *, 311 const char * 312 downloadDir ); 312 void tr_sessionSetDownloadDir( tr_handle * session, 313 const char * downloadDir ); 313 314 314 315 /** 315 316 * @brief Get the default download folder for new torrents. -
libtransmission/session.c
tr_sessionInitFull( const char * c 305 305 306 306 tr_handle * 307 307 tr_sessionInit( const char * configDir, 308 const char * downloadDir,309 308 const char * tag ) 310 309 { 311 310 return tr_sessionInitFull( configDir, 312 downloadDir,311 TR_DEFAULT_DOWNLOAD_DIR, 313 312 tag, 314 313 TR_DEFAULT_PEX_ENABLED, 315 314 TR_DEFAULT_PORT_FORWARDING_ENABLED, -
gtk/tr-prefs.c
tr_prefs_init_global( void ) 104 104 #if GLIB_CHECK_VERSION( 2, 14, 0 ) 105 105 if( !str ) str = g_get_user_special_dir( G_USER_DIRECTORY_DOWNLOAD ); 106 106 #endif 107 if( !str ) str = g_get_home_dir( );107 if( !str ) str = tr_getDefaultDownloadDir( ); 108 108 pref_string_set_default ( PREF_KEY_DOWNLOAD_DIR, str ); 109 109 110 110 pref_int_set_default ( PREF_KEY_PORT, TR_DEFAULT_PORT ); -
macosx/Controller.m
static void sleepCallback(void * control 239 239 TR_DEFAULT_PROXY_TYPE, /* reset in prefs */ 240 240 [fDefaults boolForKey: @"ProxyAuthorize"], 241 241 [[fDefaults stringForKey: @"ProxyUsername"] UTF8String], 242 ""); /* reset in prefs - from Keychain */ 242 "", /* reset in prefs - from Keychain */ 243 TR_DEFAULT_PREALLOCATE_ENABLED ); /* FIXME */ 243 244 244 245 [NSApp setDelegate: self]; 245 246 -
daemon/daemon.c
session_init( const char * configDir, 167 167 const char * password, 168 168 int blocklistEnabled ) 169 169 { 170 char * mycwd;171 170 tr_benc state, *dict = NULL; 172 171 int peerPort = -1, peers = -1; 173 172 int whitelistEnabled = -1; … … session_init( const char * configDir, 190 189 **** If neither of those can be found, the TR_DEFAULT fields are used . 191 190 ***/ 192 191 193 mycwd = tr_getcwd( );194 getConfigStr( dict, KEY_DOWNLOAD_DIR, &downloadDir, mycwd);192 getConfigStr( dict, KEY_DOWNLOAD_DIR, &downloadDir, 193 TR_DEFAULT_DOWNLOAD_DIR ); 195 194 getConfigInt( dict, KEY_PEX_ENABLED, &pexEnabled, 196 195 TR_DEFAULT_PEX_ENABLED ); 197 196 getConfigInt( dict, KEY_PORT_FORWARDING, &fwdEnabled, … … session_init( const char * configDir, 258 257 259 258 if( dict ) 260 259 tr_bencFree( &state ); 261 262 tr_free( mycwd );263 260 } 264 261 265 262 static const char * -
daemon/remote.c
15 15 #include <stdlib.h> 16 16 #include <string.h> /* strcmp */ 17 17 18 #ifdef WIN32 19 #include <direct.h> /* getcwd */ 20 #else 21 #include <unistd.h> /* getcwd */ 22 #endif 23 18 24 #include <libevent/event.h> 19 25 #include <curl/curl.h> 20 26 … … static int debug = 0; 144 150 static char * auth = NULL; 145 151 146 152 static char* 153 tr_getcwd( void ) 154 { 155 char buf[2048]; 156 *buf = '\0'; 157 #ifdef WIN32 158 _getcwd( buf, sizeof( buf ) ); 159 #else 160 getcwd( buf, sizeof( buf ) ); 161 #endif 162 return tr_strdup( buf ); 163 } 164 165 static char* 147 166 absolutify( const char * path ) 148 167 { 149 168 char * buf; -
cli/cli.c
main( int argc, 349 349 if( configdir == NULL ) 350 350 configdir = tr_getDefaultConfigDir( ); 351 351 352 /* if no download directory specified, use cwd instead */ 353 if( !downloadDir ) 354 downloadDir = tr_strdup( tr_getcwd( ) ); 352 if( downloadDir == NULL ) 353 downloadDir = tr_getDefaultDownloadDir( ); 355 354 356 355 /* Initialize libtransmission */ 357 356 h = tr_sessionInitFull(