From e5b04e45d5f408fe25a6b75b080e4dd950a227aa Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 29 Mar 2008 22:16:33 +0000 Subject: [PATCH] add tr_blocklistExists( const tr_handle * ); --- libtransmission/blocklist-test.c | 2 +- libtransmission/blocklist.c | 12 +++++++++++- libtransmission/transmission.h | 4 +++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/libtransmission/blocklist-test.c b/libtransmission/blocklist-test.c index 1522f2b1d..a95fa29d5 100644 --- a/libtransmission/blocklist-test.c +++ b/libtransmission/blocklist-test.c @@ -59,7 +59,7 @@ main( void ) /* create our own dummy blocklist */ createTestBlocklist( tmpfile ); - tr_setBlocklist( handle, tmpfile ); + tr_blocklistSet( handle, tmpfile ); /* now run some tests */ check( !tr_netResolve( "216.16.1.143", &addr ) ); diff --git a/libtransmission/blocklist.c b/libtransmission/blocklist.c index 63eee6ecf..3f0db0a48 100644 --- a/libtransmission/blocklist.c +++ b/libtransmission/blocklist.c @@ -135,8 +135,18 @@ deleteBlocklist( tr_handle * handle UNUSED ) unlink( filename ); } +int +tr_blocklistExists( const tr_handle * handle UNUSED ) +{ + struct stat st; + char filename[MAX_PATH_LENGTH]; + tr_getBlocklistFilename( filename, sizeof( filename ) ); + return !stat( filename, &st ); +} + + void -tr_setBlocklist( tr_handle * handle, +tr_blocklistSet( tr_handle * handle, const char * filename ) { FILE * in; diff --git a/libtransmission/transmission.h b/libtransmission/transmission.h index 90aec2ff3..4de64edc7 100644 --- a/libtransmission/transmission.h +++ b/libtransmission/transmission.h @@ -306,9 +306,11 @@ uint16_t tr_getGlobalPeerLimit( const tr_handle * handle ); * * Passing NULL for a filename will clear the blocklist. */ -void tr_setBlocklist( tr_handle * handle, +void tr_blocklistSet( tr_handle * handle, const char * filename ); +int tr_blocklistExists( const tr_handle * handle ); + /***********************************************************************