Changeset 6896 for trunk/libtransmission/platform.c
- Timestamp:
- Oct 14, 2008, 3:03:29 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/platform.c
r6892 r6896 296 296 if( !path ) 297 297 { 298 #ifdef __BEOS__ 298 299 char buf[MAX_PATH_LENGTH]; 299 #ifdef __BEOS__300 300 find_directory( B_USER_SETTINGS_DIRECTORY, 301 301 dev_for_path( "/boot" ), true, 302 302 buf, sizeof( buf ) ); 303 strcat( buf, "/Transmission");303 path = tr_buildPath( buf, "Transmission", NULL ); 304 304 #elif defined( SYS_DARWIN ) 305 tr_buildPath ( buf, sizeof( buf ), getHomeDir( ),306 "Library","Application Support",307 "Transmission", NULL );305 path = tr_buildPath( getHomeDir( ), "Library", 306 "Application Support", 307 "Transmission", NULL ); 308 308 #elif defined( __AMIGAOS4__ ) 309 tr_strlcpy( buf, "PROGDIR:.transmission", sizeof( buf ));309 path = tr_strdup( "PROGDIR:.transmission" ); 310 310 #elif defined( WIN32 ) 311 311 char appdata[MAX_PATH_LENGTH]; 312 312 SHGetFolderPath( NULL, CSIDL_APPDATA, NULL, 0, appdata ); 313 tr_buildPath( buf, sizeof( buf ), 314 appdata, "Transmission", NULL ); 315 #else 316 tr_buildPath ( buf, sizeof( buf ), 317 getHomeDir( ), ".transmission", NULL ); 318 #endif 319 path = tr_strdup( buf ); 313 path = tr_buildPath( appdata, "Transmission", NULL ); 314 #else 315 path = tr_buildPath( getHomeDir( ), ".transmission", NULL ); 316 #endif 320 317 } 321 318 322 319 return path; 323 320 } 321 322 #if defined(SYS_DARWIN) || defined(WIN32) 323 #define RESUME_SUBDIR "Resume" 324 #define TORRENT_SUBDIR "Torrents" 325 #else 326 #define RESUME_SUBDIR "resume" 327 #define TORRENT_SUBDIR "torrents" 328 #endif 324 329 325 330 static const char * … … 329 334 330 335 if( !path ) 331 { 332 char buf[MAX_PATH_LENGTH]; 333 const char * p = getOldConfigDir( ); 334 #if defined( __BEOS__ ) || defined( WIN32 ) || defined( SYS_DARWIN ) 335 tr_buildPath( buf, sizeof( buf ), p, "Torrents", NULL ); 336 #else 337 tr_buildPath( buf, sizeof( buf ), p, "torrents", NULL ); 338 #endif 339 340 path = tr_strdup( buf ); 341 } 336 path = tr_buildPath( getOldConfigDir( ), TORRENT_SUBDIR, NULL ); 342 337 343 338 return path; … … 351 346 if( !path ) 352 347 { 353 char buf[MAX_PATH_LENGTH];354 348 #if defined( __BEOS__ ) || defined( WIN32 ) 355 const char * p = getOldConfigDir( ); 356 tr_buildPath( buf, sizeof( buf ), p, "Cache", NULL ); 349 path = tr_buildPath( getOldConfigDir( ), "Cache", NULL ); 357 350 #elif defined( SYS_DARWIN ) 358 tr_buildPath( buf, sizeof( buf ), getHomeDir( ), 359 "Library", "Caches", "Transmission", NULL ); 360 #else 361 const char * p = getOldConfigDir( ); 362 tr_buildPath( buf, sizeof( buf ), p, "cache", NULL ); 363 #endif 364 path = tr_strdup( buf ); 351 path = tr_buildPath( getHomeDir( ), "Library", "Caches", "Transmission", NULL ); 352 #else 353 path = tr_buildPath( getOldConfigDir( ), "cache", NULL ); 354 #endif 365 355 } 366 356 … … 384 374 "." ) && strcmp( dirp->d_name, ".." ) ) 385 375 { 386 char o[MAX_PATH_LENGTH]; 387 char n[MAX_PATH_LENGTH]; 388 tr_buildPath( o, sizeof( o ), oldDir, dirp->d_name, 389 NULL ); 390 tr_buildPath( n, sizeof( n ), newDir, dirp->d_name, 391 NULL ); 376 char * o = tr_buildPath( oldDir, dirp->d_name, NULL ); 377 char * n = tr_buildPath( newDir, dirp->d_name, NULL ); 392 378 rename( o, n ); 393 379 ++count; 380 tr_free( n ); 381 tr_free( o ); 394 382 } 395 383 } … … 424 412 } 425 413 426 #if defined(SYS_DARWIN) || defined(WIN32)427 #define RESUME_SUBDIR "Resume"428 #define TORRENT_SUBDIR "Torrents"429 #else430 #define RESUME_SUBDIR "resume"431 #define TORRENT_SUBDIR "torrents"432 #endif433 434 414 void 435 415 tr_setConfigDir( tr_handle * handle, 436 416 const char * configDir ) 437 417 { 438 char buf[MAX_PATH_LENGTH];418 char * path; 439 419 440 420 handle->configDir = tr_strdup( configDir ); 441 421 442 tr_buildPath( buf, sizeof( buf ),configDir, RESUME_SUBDIR, NULL );443 tr_mkdirp( buf, 0777 );444 handle->resumeDir = tr_strdup( buf );445 446 tr_buildPath( buf, sizeof( buf ),configDir, TORRENT_SUBDIR, NULL );447 tr_mkdirp( buf, 0777 );448 handle->torrentDir = tr_strdup( buf );422 path = tr_buildPath( configDir, RESUME_SUBDIR, NULL ); 423 tr_mkdirp( path, 0777 ); 424 handle->resumeDir = path; 425 426 path = tr_buildPath( configDir, TORRENT_SUBDIR, NULL ); 427 tr_mkdirp( path, 0777 ); 428 handle->torrentDir = path; 449 429 450 430 migrateFiles( handle ); … … 476 456 if( !s ) 477 457 { 478 char path[MAX_PATH_LENGTH];479 480 458 if( ( s = getenv( "TRANSMISSION_HOME" ) ) ) 481 459 { 482 tr_strlcpy( path, s, sizeof( path ));460 s = tr_strdup( s ); 483 461 } 484 462 else 485 463 { 486 464 #ifdef SYS_DARWIN 487 tr_buildPath( path, sizeof( path ), 488 getHomeDir( ), "Library", "Application Support", 489 "Transmission", NULL ); 465 s = tr_buildPath( getHomeDir( ), "Library", 466 "Application Support", "Transmission", NULL ); 490 467 #elif defined( WIN32 ) 491 468 char appdata[MAX_PATH_LENGTH]; 492 469 SHGetFolderPath( NULL, CSIDL_APPDATA, NULL, 0, appdata ); 493 tr_buildPath( path, sizeof( path ), 494 appdata, "Transmission", NULL ); 470 s = tr_buildPath( appdata, "Transmission", NULL ); 495 471 #else 496 472 if( ( s = getenv( "XDG_CONFIG_HOME" ) ) ) 497 tr_buildPath( path, sizeof( path ), 498 s, "transmission", NULL ); 473 s = tr_buildPath( s, "transmission", NULL ); 499 474 else 500 tr_buildPath( path, sizeof( path ), 501 getHomeDir( ), ".config", "transmission", 502 NULL ); 475 s = tr_buildPath( getHomeDir( ), ".config", "transmission", NULL ); 503 476 #endif 504 477 } 505 506 s = tr_strdup( path );507 478 } 508 479 … … 518 489 { 519 490 struct stat sb; 520 char tmp[MAX_PATH_LENGTH]; 521 522 tr_buildPath( tmp, sizeof( tmp ), path, "javascript", "transmission.js", 523 NULL ); 491 char * tmp = tr_buildPath( path, "javascript", "transmission.js", NULL ); 492 const int ret = !stat( tmp, &sb ); 524 493 tr_inf( _( "Searching for web interface file \"%s\"" ), tmp ); 525 return !stat( tmp, &sb ); 494 tr_free( tmp ); 495 return ret; 496 526 497 } 527 498 … … 533 504 if( !s ) 534 505 { 535 char path[MAX_PATH_LENGTH] = { '\0' };536 537 506 if( ( s = getenv( "CLUTCH_HOME" ) ) ) 538 507 { 539 tr_strlcpy( path, s, sizeof( path ));508 s = tr_strdup( s ); 540 509 } 541 510 else if( ( s = getenv( "TRANSMISSION_WEB_HOME" ) ) ) 542 511 { 543 tr_strlcpy( path, s, sizeof( path ));512 s = tr_strdup( s ); 544 513 } 545 514 else … … 555 524 CFRelease( appRef ); 556 525 557 tr_buildPath( path, sizeof( path ), appString, "Contents", 558 "Resources", "web", 559 NULL ); 560 #elif defined( WIN32 ) 561 562 #warning\ 563 hey win32 people is this good or is there a better implementation of the next four lines 564 char appdata[MAX_PATH_LENGTH]; 526 s = tr_buildPath( appString, "Contents", "Resources", "web", NULL ); 527 #elif defined( WIN32 ) 528 529 #warning hey win32 people is this good or is there a better implementation of the next four lines 530 char appdata[MAX_PATH_LENGTH]; 565 531 SHGetFolderPath( NULL, CSIDL_APPDATA, NULL, 0, appdata ); 566 tr_buildPath( path, sizeof( path ), 567 appdata, "Transmission", NULL ); 532 s = tr_buildPath( appdata, "Transmission", NULL ); 568 533 #else 569 534 tr_list *candidates = NULL, *l; … … 573 538 if( s && *s ) 574 539 tr_list_append( &candidates, tr_strdup( s ) ); 575 else 576 { 577 char tmp[MAX_PATH_LENGTH]; 578 tr_buildPath( tmp, sizeof( tmp ), 579 getHomeDir( ), ".local", "share", NULL ); 580 tr_list_append( &candidates, tr_strdup( tmp ) ); 540 else { 541 char * dhome = tr_buildPath( getHomeDir( ), ".local", "share", NULL ); 542 tr_list_append( &candidates, dhome ); 581 543 } 582 544 … … 602 564 for( l = candidates; l; l = l->next ) 603 565 { 604 tr_buildPath( path, sizeof( path ), l->data, "transmission", 605 "web", 606 NULL ); 607 if( isClutchDir( path ) ) 566 char * path = tr_buildPath( l->data, "transmission", "web", NULL ); 567 const int found = isClutchDir( path ); 568 tr_free( path ); 569 if( found ) { 570 s = path; 608 571 break; 609 *path = '\0';572 } 610 573 } 611 574 … … 613 576 #endif 614 577 } 615 616 s = tr_strdup( path );617 578 } 618 579
Note: See TracChangeset
for help on using the changeset viewer.