Changeset 11594 for trunk/daemon/watch.c


Ignore:
Timestamp:
Dec 24, 2010, 3:41:10 PM (11 years ago)
Author:
charles
Message:

(trunk daemon) get the non-inotify chunks of code working with libevent2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/watch.c

    r11590 r11594  
    167167    evbuffer_free( w->lastFiles );
    168168}
     169
     170static char*
     171get_key_from_file( const char * filename, const size_t len )
     172{
     173    return tr_strdup_printf( "%c%*.*s%d", FILE_DELIMITER, (int)len, (int)len, filename, FILE_DELIMITER );
     174}
     175
    169176static void
    170177add_file_to_list( struct evbuffer * buf, const char * filename, size_t len )
    171178{
    172     const char delimiter = FILE_DELIMITER;
    173     evbuffer_add( buf, &delimiter, 1 );
    174     evbuffer_add( buf, filename, len );
    175     evbuffer_add( buf, &delimiter, 1 );
     179    char * key = get_key_from_file( filename, len );
     180    evbuffer_add( buf, key, strlen( key ) );
     181    tr_free( key );
    176182}
    177183static tr_bool
     
    179185{
    180186    tr_bool in_list;
    181     struct evbuffer * test = evbuffer_new( );
    182     add_file_to_list( test, filename, len );
    183     in_list = evbuffer_find( buf, EVBUFFER_DATA( test ), EVBUFFER_LENGTH( test ) ) != NULL;
    184     evbuffer_free( test );
     187    struct evbuffer_ptr ptr;
     188    char * key = get_key_from_file( filename, len );
     189
     190    ptr = evbuffer_search( buf, key, strlen( key ), NULL );
     191    in_list = ptr.pos != -1;
     192
     193    tr_free( key );
    185194    return in_list;
    186195}
Note: See TracChangeset for help on using the changeset viewer.