Changeset 6319 for trunk/libtransmission/platform.c
- Timestamp:
- Jul 11, 2008, 4:07:14 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/platform.c
r5843 r6319 51 51 52 52 #include "transmission.h" 53 #include "list.h" 53 54 #include "platform.h" 54 55 #include "utils.h" … … 509 510 ***/ 510 511 512 static int 513 isClutchDir( const char * path ) 514 { 515 struct stat sb; 516 char tmp[MAX_PATH_LENGTH]; 517 tr_buildPath( tmp, sizeof( tmp ), path, "javascript", "transmission.js", NULL ); 518 fprintf( stderr, "path is [%s]; testing [%s] for clutch\n", path, tmp ); 519 return !stat( tmp, &sb ); 520 } 521 522 const char * 523 tr_getClutchDir( const tr_session * session UNUSED ) 524 { 525 static char * s = NULL; 526 527 if( !s ) 528 { 529 char path[MAX_PATH_LENGTH]; 530 531 if(( s = getenv( "CLUTCH_HOME" ))) 532 { 533 snprintf( path, sizeof( path ), s ); 534 } 535 else 536 { 537 #ifdef SYS_DARWIN 538 #error not implemented 539 #elif defined(WIN32) 540 #warning hey win32 people is this good or is there a better implementation of the next four lines 541 char appdata[MAX_PATH_LENGTH]; 542 SHGetFolderPath( NULL, CSIDL_APPDATA, NULL, 0, appdata ); 543 tr_buildPath( path, sizeof( path ), 544 appdata, "Transmission", NULL ); 545 #else 546 tr_list *candidates=NULL, *l; 547 548 /* XDG_DATA_HOME should be the first in the list of candidates */ 549 s = getenv( "XDG_DATA_HOME" ); 550 if( s && *s ) 551 tr_list_append( &candidates, tr_strdup( s ) ); 552 else { 553 char tmp[MAX_PATH_LENGTH]; 554 tr_buildPath( tmp, sizeof( tmp ), getHomeDir(), ".local", "share", NULL ); 555 tr_list_append( &candidates, tr_strdup( tmp ) ); 556 } 557 558 /* XDG_DATA_DIRS are the backup directories */ 559 s = getenv( "XDG_DATA_DIRS" ); 560 if( !s || !*s ) 561 s = "/usr/local/share/:/usr/share/"; 562 while( s && *s ) { 563 char * end = strchr( s, ':' ); 564 if( end ) { 565 tr_list_append( &candidates, tr_strndup( s, end-s ) ); 566 s = end + 1; 567 } else { 568 tr_list_append( &candidates, tr_strdup( s ) ); 569 break; 570 } 571 } 572 573 for( l=candidates; l; l=l->next ) { 574 tr_buildPath( path, sizeof( path ), l->data, "transmission", "clutch", NULL ); 575 if( isClutchDir( path ) ) 576 break; 577 *path = '\0'; 578 } 579 580 tr_list_free( &candidates, tr_free ); 581 #endif 582 } 583 584 if( !*path ) 585 { 586 tr_err( _( "Unable to find web interface files" ) ); 587 tr_strlcpy( path, "/dev/null", sizeof( path ) ); 588 } 589 590 s = tr_strdup( path ); 591 } 592 593 return s; 594 } 595 596 597 /*** 598 **** 599 ***/ 600 511 601 int 512 602 tr_lockfile( const char * filename )
Note: See TracChangeset
for help on using the changeset viewer.