(trunk daemon) get the non-inotify chunks of code working with libevent2
This commit is contained in:
parent
a3a7b1548d
commit
a5e2b244dd
|
@ -166,22 +166,31 @@ watchdir_free_impl( dtr_watchdir * w )
|
||||||
{
|
{
|
||||||
evbuffer_free( w->lastFiles );
|
evbuffer_free( w->lastFiles );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char*
|
||||||
|
get_key_from_file( const char * filename, const size_t len )
|
||||||
|
{
|
||||||
|
return tr_strdup_printf( "%c%*.*s%d", FILE_DELIMITER, (int)len, (int)len, filename, FILE_DELIMITER );
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_file_to_list( struct evbuffer * buf, const char * filename, size_t len )
|
add_file_to_list( struct evbuffer * buf, const char * filename, size_t len )
|
||||||
{
|
{
|
||||||
const char delimiter = FILE_DELIMITER;
|
char * key = get_key_from_file( filename, len );
|
||||||
evbuffer_add( buf, &delimiter, 1 );
|
evbuffer_add( buf, key, strlen( key ) );
|
||||||
evbuffer_add( buf, filename, len );
|
tr_free( key );
|
||||||
evbuffer_add( buf, &delimiter, 1 );
|
|
||||||
}
|
}
|
||||||
static tr_bool
|
static tr_bool
|
||||||
is_file_in_list( struct evbuffer * buf, const char * filename, size_t len )
|
is_file_in_list( struct evbuffer * buf, const char * filename, size_t len )
|
||||||
{
|
{
|
||||||
tr_bool in_list;
|
tr_bool in_list;
|
||||||
struct evbuffer * test = evbuffer_new( );
|
struct evbuffer_ptr ptr;
|
||||||
add_file_to_list( test, filename, len );
|
char * key = get_key_from_file( filename, len );
|
||||||
in_list = evbuffer_find( buf, EVBUFFER_DATA( test ), EVBUFFER_LENGTH( test ) ) != NULL;
|
|
||||||
evbuffer_free( test );
|
ptr = evbuffer_search( buf, key, strlen( key ), NULL );
|
||||||
|
in_list = ptr.pos != -1;
|
||||||
|
|
||||||
|
tr_free( key );
|
||||||
return in_list;
|
return in_list;
|
||||||
}
|
}
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue